treewide: adopt flakes
after using non-flake setup time has arrived to switch to flakes eeleco clearly won and flakes are the future
This commit is contained in:
parent
e3264f1451
commit
c5246a1b46
9 changed files with 231 additions and 140 deletions
32
default.nix
32
default.nix
|
@ -1,31 +1 @@
|
|||
# if evaluating outside of the store, copy the current directory to the store and import it
|
||||
# filtering out .gitignore files and .git directories
|
||||
# if evaluating inside the store, import the outputs.nix file
|
||||
|
||||
let
|
||||
# Ideally this file should be selfcontained, but I like the utilities in nixpkgs lib
|
||||
lib = (import "${(import ./inputs.nix {}).nixpkgs}/lib").extend (self: super: {
|
||||
proot = import ./lib/gitignore-filter.nix { lib = self; };
|
||||
inherit (self.proot) parseGitignore runGitignoreFilter toGitignoreMatcher;
|
||||
});
|
||||
|
||||
currentFilePath = (builtins.unsafeGetAttrPos "any" { any = "any"; }).file;
|
||||
storePathLength = builtins.stringLength (builtins.toString builtins.storeDir);
|
||||
evaluatingInStore = (builtins.substring 0 storePathLength currentFilePath) == builtins.storeDir;
|
||||
|
||||
selfInStore = builtins.path {
|
||||
path = ./.;
|
||||
name = "source";
|
||||
filter = path: type:
|
||||
let
|
||||
selfPath = builtins.dirOf currentFilePath;
|
||||
gitIgnoreFilters = lib.parseGitignore selfPath path;
|
||||
result = type != "unknown"
|
||||
&& type != "symlink"
|
||||
&& builtins.baseNameOf path != ".git"
|
||||
&& lib.runGitignoreFilter gitIgnoreFilters path type;
|
||||
in result;
|
||||
};
|
||||
in
|
||||
if !(evaluatingInStore) then { ... }@args: import selfInStore ({ selfPath = selfInStore; } // args )
|
||||
else { ... }@args: import ./outputs.nix ({ selfPath = selfInStore; } // args)
|
||||
_: builtins.getFlake (builtins.toString ./.)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue