lib: one line for arguments, drop userFlake*

Also format all files and add a flake.lock for lib
for a folder thats meant to work on other flakes theres never a reason
it should need to refer to itself, only other flakes. So "self" and
"inputs" are better namings for these variables. The userFlake* is
redundant and confusing, when trying to call the functions its hard to
figure out how to use them when there are now two lines of arguments to
figure out.
This commit is contained in:
Pacman99 2021-04-23 18:13:03 -07:00
parent fe9ba26561
commit eab0bf074c
19 changed files with 328 additions and 199 deletions

View File

@ -81,7 +81,7 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"narHash": "sha256-aGpcPxOBIPnwj6uLNtpKefZjEbDkZnMHZ2mH12veHnY=", "narHash": "sha256-LvO5VwFNFzb2xbmgw+fWhkrRY1KMlp5vxqQU/BqS0H8=",
"path": "./lib", "path": "./lib",
"type": "path" "type": "path"
}, },
@ -280,7 +280,7 @@
] ]
}, },
"locked": { "locked": {
"narHash": "sha256-XG4TOZObj2Wd8KiqnHgtlWjjMbJOIJB7+DxUFzMCXw8=", "narHash": "sha256-Zs7dc0dNNa0Z3//+Gckxj7SKrMqVovY0xZZ1z8xWnEg=",
"path": "./pkgs", "path": "./pkgs",
"type": "path" "type": "path"
}, },
@ -337,11 +337,11 @@
}, },
"utils_2": { "utils_2": {
"locked": { "locked": {
"lastModified": 1618217525, "lastModified": 1618868421,
"narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=", "narHash": "sha256-vyoJhLV6cJ8/tWz+l9HZLIkb9Rd9esE7p+0RL6zDR6Y=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c6169a2772643c4a93a0b5ac1c61e296cba68544", "rev": "eed214942bcfb3a8cc09eb3b28ca7d7221e44a94",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -9,7 +9,7 @@
profileMap = list: map (profile: profile.default) (lib.flatten list); profileMap = list: map (profile: profile.default) (lib.flatten list);
mkNodes = import ./mkNodes.nix { inherit lib; }; mkNodes = import ./mkNodes.nix { inherit lib; };
mkHosts = import ./mkHosts.nix { inherit lib; }; mkHosts = import ./mkHosts.nix { inherit lib; };

View File

@ -1,8 +1,7 @@
{ lib }: { lib }:
{ userFlakeNixOS, userFlakeSelf, userFlakeInputs }: { self, nixos, inputs, modules, ... } @ allArgs:
let args = builtins.removeAttrs allArgs [ "self" "nixos" "inputs" ]; in
{ modules, ... } @ args:
lib.nixosSystem (args // { lib.nixosSystem (args // {
modules = modules =
let let
@ -15,7 +14,7 @@ lib.nixosSystem (args // {
(args // { (args // {
modules = moduleList ++ [ modules = moduleList ++ [
"${userFlakeNixOS}/${modpath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" "${nixos}/${modpath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix"
({ config, suites, ... }: { ({ config, suites, ... }: {
@ -25,15 +24,15 @@ lib.nixosSystem (args // {
disabledModules = map (x: [ x ]) disabledModules = map (x: [ x ])
(lib.remove modules.core suites.allProfiles); (lib.remove modules.core suites.allProfiles);
nix.registry = lib.mapAttrs (n: v: { flake = v; }) userFlakeInputs; nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs;
isoImage.isoBaseName = "nixos-" + config.networking.hostName; isoImage.isoBaseName = "nixos-" + config.networking.hostName;
isoImage.contents = [{ isoImage.contents = [{
source = userFlakeSelf; source = self;
target = "/devos/"; target = "/devos/";
}]; }];
isoImage.storeContents = [ isoImage.storeContents = [
userFlakeSelf.devShell.${config.nixpkgs.system} self.devShell.${config.nixpkgs.system}
# include also closures that are "switched off" by the # include also closures that are "switched off" by the
# above profile filter on the local config attribute # above profile filter on the local config attribute
fullHostConfig.system.build.toplevel fullHostConfig.system.build.toplevel

View File

@ -1,6 +1,6 @@
{ lib }: { lib }:
{ userFlakeSelf }: nixosConfigurations:
with lib; with lib;
let let
@ -8,7 +8,7 @@ let
mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home) mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home)
config.config.system.build.homes; config.config.system.build.homes;
hmConfigs = mapAttrs mkHomes userFlakeSelf.nixosConfigurations; hmConfigs = mapAttrs mkHomes nixosConfigurations;
in in
foldl recursiveUpdate { } (attrValues hmConfigs) foldl recursiveUpdate { } (attrValues hmConfigs)

View File

@ -1,8 +1,6 @@
{ lib }: { lib }:
{ userFlakeNixOS, userFlakeInputs, userFlakeSelf }: { self, nixos, inputs, dir, extern, suites, overrides, multiPkgs }:
{ dir, extern, suites, overrides, multiPkgs }:
let let
defaultSystem = "x86_64-linux"; defaultSystem = "x86_64-linux";
@ -31,24 +29,24 @@ let
useUserPackages = true; useUserPackages = true;
extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; }; extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
sharedModules = extern.userModules ++ (builtins.attrValues userFlakeSelf.homeModules); sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
}; };
users.mutableUsers = lib.mkDefault false; users.mutableUsers = lib.mkDefault false;
hardware.enableRedistributableFirmware = lib.mkDefault true; hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [ nix.nixPath = [
"nixpkgs=${userFlakeNixOS}" "nixpkgs=${nixos}"
"nixos-config=${userFlakeSelf}/lib/compat/nixos" "nixos-config=${self}/lib/compat/nixos"
"home-manager=${userFlakeInputs.home}" "home-manager=${inputs.home}"
]; ];
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system}; nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
nix.registry = { nix.registry = {
devos.flake = userFlakeSelf; devos.flake = self;
nixos.flake = userFlakeNixOS; nixos.flake = nixos;
override.flake = userFlakeInputs.override; override.flake = inputs.override;
}; };
nix.package = pkgs.nixFlakes; nix.package = pkgs.nixFlakes;
@ -59,13 +57,13 @@ let
} }
''; '';
system.configurationRevision = lib.mkIf (userFlakeSelf ? rev) userFlakeSelf.rev; system.configurationRevision = lib.mkIf (self ? rev) self.rev;
}; };
# Everything in `./modules/list.nix`. # Everything in `./modules/list.nix`.
flakeModules = { imports = builtins.attrValues userFlakeSelf.nixosModules ++ extern.modules; }; flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
cachix = let rootCachix = "${userFlakeSelf}/cachix.nix"; in cachix = let rootCachix = "${self}/cachix.nix"; in
if builtins.pathExists rootCachix if builtins.pathExists rootCachix
then rootCachix then rootCachix
else { } else { }
@ -84,7 +82,7 @@ let
networking = { inherit hostName; }; networking = { inherit hostName; };
_module.args = { _module.args = {
self = userFlakeSelf; self = self;
hosts = builtins.mapAttrs (_: host: host.config) hosts = builtins.mapAttrs (_: host: host.config)
(removeAttrs hosts [ hostName ]); (removeAttrs hosts [ hostName ]);
}; };
@ -97,9 +95,7 @@ let
}; };
in in
lib.os.devosSystem { lib.os.devosSystem {
inherit userFlakeNixOS userFlakeInputs userFlakeSelf; inherit self nixos inputs specialArgs;
} {
inherit specialArgs;
system = defaultSystem; system = defaultSystem;
modules = modules // { inherit local; }; modules = modules // { inherit local; };
}; };

View File

@ -1,10 +1,7 @@
{ lib }: { lib }:
{ userFlakeSelf }: { overlay, overlays, pkgs }:
{ pkgs }:
let let
inherit (userFlakeSelf) overlay overlays;
packagesNames = lib.attrNames (overlay null null) packagesNames = lib.attrNames (overlay null null)
++ lib.attrNames (lib.concatAttrs ++ lib.attrNames (lib.concatAttrs
(lib.attrValues (lib.attrValues

View File

@ -1,12 +1,10 @@
{ lib, utils }: { lib, utils }:
{ userFlakeNixOS, userFlakeSelf, userFlakeInputs }: { self, nixos, inputs, extern, overrides }:
{ extern, overrides }:
(utils.lib.eachDefaultSystem (utils.lib.eachDefaultSystem
(system: (system:
let let
overridePkgs = lib.os.pkgImport userFlakeInputs.override [ ] system; overridePkgs = lib.os.pkgImport inputs.override [ ] system;
overridesOverlay = overrides.packages; overridesOverlay = overrides.packages;
overlays = [ overlays = [
@ -17,11 +15,11 @@
}); });
}) })
(overridesOverlay overridePkgs) (overridesOverlay overridePkgs)
userFlakeSelf.overlay self.overlay
] ]
++ extern.overlays ++ extern.overlays
++ (lib.attrValues userFlakeSelf.overlays); ++ (lib.attrValues self.overlays);
in in
{ pkgs = lib.os.pkgImport userFlakeNixOS overlays system; } { pkgs = lib.os.pkgImport nixos overlays system; }
) )
).pkgs ).pkgs

View File

@ -2,16 +2,16 @@
let mkProfileAttrs = let mkProfileAttrs =
/** /**
Synopsis: mkProfileAttrs _path_ Synopsis: mkProfileAttrs _path_
Recursively collect the subdirs of _path_ containing a default.nix into attrs. Recursively collect the subdirs of _path_ containing a default.nix into attrs.
This sets a contract, eliminating ambiguity for _default.nix_ living under the This sets a contract, eliminating ambiguity for _default.nix_ living under the
profile directory. profile directory.
Example: Example:
let profiles = mkProfileAttrs ./profiles; in let profiles = mkProfileAttrs ./profiles; in
assert profiles ? core.default; 0 assert profiles ? core.default; 0
**/ **/
dir: dir:
let let
imports = imports =

147
lib/flake.lock Normal file
View File

@ -0,0 +1,147 @@
{
"nodes": {
"deploy": {
"inputs": {
"flake-compat": "flake-compat",
"naersk": "naersk",
"nixpkgs": "nixpkgs",
"utils": "utils"
},
"locked": {
"lastModified": 1616406726,
"narHash": "sha256-n9zmgxR03QNrvs9/fHewqE0j3SjL7Y+cglBCFu3U3rg=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "deploy-rs",
"type": "github"
}
},
"devshell": {
"locked": {
"lastModified": 1618523768,
"narHash": "sha256-Gev9da35pHUey3kGz/zrJFc/9ICs++vPCho7qB1mqd8=",
"owner": "numtide",
"repo": "devshell",
"rev": "709fe4d04a9101c9d224ad83f73416dce71baf21",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1606424373,
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1610392286,
"narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=",
"owner": "nmattia",
"repo": "naersk",
"rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be",
"type": "github"
},
"original": {
"owner": "nmattia",
"ref": "master",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1610942247,
"narHash": "sha256-PKo1ATAlC6BmfYSRmX0TVmNoFbrec+A5OKcabGEu2yU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7d71001b796340b219d1bfa8552c81995017544a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1619244632,
"narHash": "sha256-IDcbMRnyKO9WlQ5xzIlM3HfWAUKTy+3xSd+CvDGiLgE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5cecebfb2f76da7b93f19967e99b3ff4fb4d2850",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"deploy": "deploy",
"devshell": "devshell",
"nixpkgs": "nixpkgs_2",
"utils": "utils_2"
}
},
"utils": {
"locked": {
"lastModified": 1610051610,
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1618868421,
"narHash": "sha256-vyoJhLV6cJ8/tWz+l9HZLIkb9Rd9esE7p+0RL6zDR6Y=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "eed214942bcfb3a8cc09eb3b28ca7d7221e44a94",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -4,87 +4,84 @@
inputs = inputs =
{ {
deploy.url = "github:serokell/deploy-rs"; deploy.url = "github:serokell/deploy-rs";
deploy.inputs = {
utils.follows = "utils";
};
devshell.url = "github:numtide/devshell"; devshell.url = "github:numtide/devshell";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
}; };
outputs = inputs@{ self, nixpkgs, deploy, devshell, utils, ... }: let outputs = inputs@{ self, nixpkgs, deploy, devshell, utils, ... }:
lib = nixpkgs.lib.makeExtensible (self:
let
attrs = import ./attrs.nix { lib = nixpkgs.lib // self; };
lists = import ./lists.nix { lib = nixpkgs.lib // self; };
strings = import ./strings.nix { lib = nixpkgs.lib // self; };
in
utils.lib
//
{
os = import ./devos {
lib = nixpkgs.lib // self;
inherit utils;
};
mkFlake = {
__functor = import ./mkFlake {
lib = nixpkgs.lib // self;
inherit deploy;
};
evalArgs = import ./mkFlake/evalArgs.nix { lib = nixpkgs.lib // self; };
evalOldArgs = import ./mkFlake/evalOldArgs.nix { lib = nixpkgs.lib // self; };
};
pkgs-lib = import ./pkgs-lib {
lib = nixpkgs.lib // self;
inherit nixpkgs deploy devshell;
};
inherit (attrs)
mapFilterAttrs
genAttrs'
safeReadDir
pathsToImportedAttrs
concatAttrs
filterPackages;
inherit (lists) pathsIn;
inherit (strings) rgxToString;
}
);
jobs = import ./jobs { inherit nixpkgs; lib = nixpkgs.lib // lib; };
in
{
inherit jobs;
lib = utils.lib // {
inherit (lib)
mkFlake;
};
}
//
utils.lib.eachDefaultSystem (system:
let let
nixpkgs' = import nixpkgs { inherit system; overlays = []; config = {}; };
lib = nixpkgs.lib.makeExtensible (self:
let
attrs = import ./attrs.nix { lib = nixpkgs.lib // self; };
lists = import ./lists.nix { lib = nixpkgs.lib // self; };
strings = import ./strings.nix { lib = nixpkgs.lib // self; };
in
utils.lib
//
{
os = import ./devos {
lib = nixpkgs.lib // self;
inherit utils;
};
mkFlake = {
__functor = import ./mkFlake {
lib = nixpkgs.lib // self;
inherit deploy;
};
evalArgs = import ./mkFlake/evalArgs.nix { lib = nixpkgs.lib // self; };
evalOldArgs = import ./mkFlake/evalOldArgs.nix { lib = nixpkgs.lib // self; };
};
pkgs-lib = import ./pkgs-lib {
lib = nixpkgs.lib // self;
inherit nixpkgs deploy devshell;
};
inherit (attrs)
mapFilterAttrs
genAttrs'
safeReadDir
pathsToImportedAttrs
concatAttrs
filterPackages;
inherit (lists) pathsIn;
inherit (strings) rgxToString;
}
);
jobs = import ./jobs { inherit nixpkgs; lib = nixpkgs.lib // lib; };
in in
{
inherit jobs;
lib = utils.lib // {
inherit (lib)
mkFlake;
};
}
//
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{ {
checks = { checks = {
tests = import ./tests { tests = import ./tests {
inherit (nixpkgs') pkgs; inherit pkgs;
lib = nixpkgs.lib // lib; lib = nixpkgs.lib // lib;
}; };
}; };
} }
); );
} }

View File

@ -1,5 +1,7 @@
{ nixpkgs, lib, system ? "x86_64-linux" }: let { nixpkgs, lib, system ? "x86_64-linux" }:
pkgs = import nixpkgs { inherit system; overlays = []; config = {}; }; let
in { pkgs = import nixpkgs { inherit system; overlays = [ ]; config = { }; };
in
{
mkFlakeDoc = import ./mkFlakeDoc.nix { inherit pkgs lib; }; mkFlakeDoc = import ./mkFlakeDoc.nix { inherit pkgs lib; };
} }

View File

@ -22,9 +22,7 @@ let
''; '';
options = ( options = (
lib.mkFlake.evalArgs lib.mkFlake.evalArgs { nixos = "nixos"; args = { }; }
{ userFlakeSelf = {}; userFlakeNixOS = {}; }
{ args = { }; }
).options; ).options;
processedOptions = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix; processedOptions = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix;

View File

@ -6,31 +6,26 @@ in
_: { self, inputs, nixos, ... } @ args: _: { self, inputs, nixos, ... } @ args:
let let
userFlakeSelf = self;
userFlakeInputs = inputs;
userFlakeNixOS = nixos;
cfg = ( cfg = (
lib.mkFlake.evalOldArgs lib.mkFlake.evalOldArgs
{ inherit userFlakeSelf userFlakeInputs; } { inherit self inputs args; }
{ inherit args; }
).config; ).config;
multiPkgs = os.mkPkgs multiPkgs = os.mkPkgs
{ inherit userFlakeSelf userFlakeInputs userFlakeNixOS; } {
{ inherit (cfg) extern overrides; }; inherit self inputs nixos;
inherit (cfg) extern overrides;
};
outputs = { outputs = {
nixosConfigurations = os.mkHosts nixosConfigurations = os.mkHosts
{ inherit userFlakeSelf userFlakeInputs userFlakeNixOS; }
{ {
inherit multiPkgs; inherit self inputs nixos multiPkgs;
inherit (cfg) extern suites overrides; inherit (cfg) extern suites overrides;
dir = cfg.hosts; dir = cfg.hosts;
}; };
homeConfigurations = os.mkHomeConfigurations homeConfigurations = os.mkHomeConfigurations self.nixosConfigurations;
{ inherit userFlakeSelf; };
nixosModules = cfg.modules; nixosModules = cfg.modules;
@ -39,7 +34,7 @@ let
overlay = cfg.packages; overlay = cfg.packages;
inherit (cfg) overlays; inherit (cfg) overlays;
deploy.nodes = os.mkNodes deploy userFlakeSelf.nixosConfigurations; deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
}; };
systemOutputs = lib.eachDefaultSystem (system: systemOutputs = lib.eachDefaultSystem (system:
@ -47,15 +42,16 @@ let
pkgs = multiPkgs.${system}; pkgs = multiPkgs.${system};
pkgs-lib = lib.pkgs-lib.${system}; pkgs-lib = lib.pkgs-lib.${system};
# all packages that are defined in ./pkgs # all packages that are defined in ./pkgs
legacyPackages = os.mkPackages legacyPackages = os.mkPackages {
{ inherit userFlakeSelf; } inherit pkgs;
{ inherit pkgs; }; inherit (self) overlay overlays;
};
in in
{ {
checks = pkgs-lib.tests.mkChecks { checks = pkgs-lib.tests.mkChecks {
inherit (userFlakeSelf.deploy) nodes; inherit (self.deploy) nodes;
hosts = userFlakeSelf.nixosConfigurations; hosts = self.nixosConfigurations;
homes = userFlakeSelf.homeConfigurations; homes = self.homeConfigurations;
}; };
inherit legacyPackages; inherit legacyPackages;

View File

@ -1,8 +1,6 @@
{ lib }: { lib }:
{ userFlakeSelf, userFlakeNixOS }: { nixos, args }:
{ args }:
let let
argOpts = with lib; { config, ... }: argOpts = with lib; { config, ... }:
let let
@ -51,10 +49,10 @@ let
options = with types; { options = with types; {
input = mkOption { input = mkOption {
type = flakeType; type = flakeType;
default = userFlakeNixOS; default = nixos;
description = '' description = ''
nixpkgs flake input to use for this channel nixpkgs flake input to use for this channel
''; '';
}; };
overlays = mkOption { overlays = mkOption {
type = pathToListOf overlayType; type = pathToListOf overlayType;
@ -198,7 +196,7 @@ let
let let
default = { default = {
nixpkgs = { nixpkgs = {
input = userFlakeNixOS; input = nixos;
}; };
}; };
in in

View File

@ -1,8 +1,6 @@
{ lib }: { lib }:
{ userFlakeSelf, userFlakeInputs }: { self, inputs, args }:
{ args }:
let let
argOpts = with lib; { config, options, ... }: argOpts = with lib; { config, options, ... }:
let let
@ -32,8 +30,8 @@ let
}; };
hosts = mkOption { hosts = mkOption {
type = path; type = path;
default = "${userFlakeSelf}/hosts"; default = "${self}/hosts";
defaultText = "\${userFlakeSelf}/hosts"; defaultText = "\${self}/hosts";
apply = toString; apply = toString;
description = '' description = ''
Path to directory containing host configurations that will be exported Path to directory containing host configurations that will be exported
@ -74,15 +72,15 @@ let
}; };
profiles = mkOption { profiles = mkOption {
type = path; type = path;
default = "${userFlakeSelf}/profiles"; default = "${self}/profiles";
defaultText = "\${userFlakeSelf}/profiles"; defaultText = "\${self}/profiles";
apply = x: os.mkProfileAttrs (toString x); apply = x: os.mkProfileAttrs (toString x);
description = "path to profiles folder that can be collected into suites"; description = "path to profiles folder that can be collected into suites";
}; };
userProfiles = mkOption { userProfiles = mkOption {
type = path; type = path;
default = "${userFlakeSelf}/users/profiles"; default = "${self}/users/profiles";
defaultText = "\${userFlakeSelf}/users/profiles"; defaultText = "\${self}/users/profiles";
apply = x: os.mkProfileAttrs (toString x); apply = x: os.mkProfileAttrs (toString x);
description = "path to user profiles folder that can be collected into userSuites"; description = "path to user profiles folder that can be collected into userSuites";
}; };
@ -107,8 +105,8 @@ let
}; };
users = mkOption { users = mkOption {
type = path; type = path;
default = "${userFlakeSelf}/users"; default = "${self}/users";
defaultText = "\${userFlakeSelf}/users"; defaultText = "\${self}/users";
apply = x: os.mkProfileAttrs (toString x); apply = x: os.mkProfileAttrs (toString x);
description = '' description = ''
path to folder containing profiles that define system users path to folder containing profiles that define system users
@ -131,9 +129,9 @@ let
{ modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; } { modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; }
''; '';
# So unneeded extern attributes can safely be deleted # So unneeded extern attributes can safely be deleted
apply = x: defaults // (x { inputs = userFlakeInputs // userFlakeSelf.inputs; }); apply = x: defaults // (x { inputs = inputs // self.inputs; });
description = '' description = ''
Function with argument 'inputs' that contains all devos and ''${userFlakeSelf}'s inputs. Function with argument 'inputs' that contains all devos and ''${self}'s inputs.
The function should return an attribute set with modules, overlays, and The function should return an attribute set with modules, overlays, and
specialArgs to be included across nixos and home manager configurations. specialArgs to be included across nixos and home manager configurations.
Only attributes that are used should be returned. Only attributes that are used should be returned.
@ -141,8 +139,8 @@ let
}; };
overlays = mkOption { overlays = mkOption {
type = path; type = path;
default = "${userFlakeSelf}/overlays"; default = "${self}/overlays";
defaultText = "\${userFlakeSelf}/overlays"; defaultText = "\${self}/overlays";
apply = x: lib.pathsToImportedAttrs (lib.pathsIn (toString x)); apply = x: lib.pathsToImportedAttrs (lib.pathsIn (toString x));
description = '' description = ''
path to folder containing overlays which will be applied to pkgs and exported in path to folder containing overlays which will be applied to pkgs and exported in

View File

@ -1,9 +1,13 @@
{ lib, nixpkgs, deploy, devshell }: { lib, nixpkgs, deploy, devshell }:
lib.genAttrs lib.genAttrs
lib.defaultSystems (system: lib.defaultSystems
(system:
let
pkgs = import nixpkgs { inherit system; };
in
{ {
tests = import ./tests { inherit lib deploy nixpkgs system; }; tests = import ./tests { inherit lib deploy nixpkgs pkgs system; };
shell = import ./shell { inherit lib devshell deploy nixpkgs system; }; shell = import ./shell { inherit lib devshell deploy nixpkgs system; };
} }
) )

View File

@ -11,7 +11,7 @@ let
]; ];
pkgs = import nixpkgs { inherit system overlays; config = {}; }; pkgs = import nixpkgs { inherit system overlays; config = { }; };
flk = pkgs.callPackage ./flk.nix { }; flk = pkgs.callPackage ./flk.nix { };

View File

@ -1,7 +1,5 @@
{ lib, nixpkgs, deploy, system }: { lib, nixpkgs, pkgs, deploy, system }:
let let
pkgs = import nixpkgs { inherit system; overlays = []; config = {}; };
mkChecks = { hosts, nodes, homes ? { } }: mkChecks = { hosts, nodes, homes ? { } }:
let let
deployHosts = lib.filterAttrs deployHosts = lib.filterAttrs
@ -9,9 +7,10 @@ let
nodes; nodes;
deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; }; deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; };
tests = tests =
lib.optionalAttrs (deployHosts != { }) { lib.optionalAttrs (deployHosts != { })
profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))}); {
} // lib.mapAttrs (n: v: v.activationPackage) homes; profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))});
} // lib.mapAttrs (n: v: v.activationPackage) homes;
in in
lib.recursiveUpdate tests deployChecks; lib.recursiveUpdate tests deployChecks;

View File

@ -1,27 +1,27 @@
{ pkgs, lib }: { pkgs, lib }:
pkgs.runCommandNoCC "devos-lib-tests" pkgs.runCommandNoCC "devos-lib-tests"
{ {
buildInputs = [ buildInputs = [
pkgs.nix pkgs.nix
( (
let tests = import ./lib.nix { inherit pkgs lib; }; in let tests = import ./lib.nix { inherit pkgs lib; }; in
if tests == [ ] then null if tests == [ ] then null
else throw (builtins.toJSON tests) else throw (builtins.toJSON tests)
) )
]; ];
} '' } ''
datadir="${pkgs.nix}/share" datadir="${pkgs.nix}/share"
export TEST_ROOT=$(pwd)/test-tmp export TEST_ROOT=$(pwd)/test-tmp
export NIX_BUILD_HOOK= export NIX_BUILD_HOOK=
export NIX_CONF_DIR=$TEST_ROOT/etc export NIX_CONF_DIR=$TEST_ROOT/etc
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
export NIX_STATE_DIR=$TEST_ROOT/var/nix export NIX_STATE_DIR=$TEST_ROOT/var/nix
export NIX_STORE_DIR=$TEST_ROOT/store export NIX_STORE_DIR=$TEST_ROOT/store
export PAGER=cat export PAGER=cat
cacheDir=$TEST_ROOT/binary-cache cacheDir=$TEST_ROOT/binary-cache
nix-store --init nix-store --init
touch $out touch $out
'' ''