From eab0bf074c221a5dcd810aa587dfac5b17d01ae5 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Fri, 23 Apr 2021 18:13:03 -0700 Subject: [PATCH] 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. --- flake.lock | 10 +- lib/devos/default.nix | 2 +- lib/devos/devosSystem.nix | 13 ++- lib/devos/mkHomeConfigurations.nix | 4 +- lib/devos/mkHosts.nix | 32 +++---- lib/devos/mkPackages.nix | 5 +- lib/devos/mkPkgs.nix | 12 +-- lib/devos/mkProfileAttrs.nix | 16 ++-- lib/flake.lock | 147 +++++++++++++++++++++++++++++ lib/flake.nix | 135 +++++++++++++------------- lib/jobs/default.nix | 8 +- lib/jobs/mkFlakeDoc.nix | 4 +- lib/mkFlake/default.nix | 34 +++---- lib/mkFlake/evalArgs.nix | 10 +- lib/mkFlake/evalOldArgs.nix | 28 +++--- lib/pkgs-lib/default.nix | 8 +- lib/pkgs-lib/shell/default.nix | 2 +- lib/pkgs-lib/tests/default.nix | 11 +-- lib/tests/default.nix | 46 ++++----- 19 files changed, 328 insertions(+), 199 deletions(-) create mode 100644 lib/flake.lock diff --git a/flake.lock b/flake.lock index f2b65a3..00b0728 100644 --- a/flake.lock +++ b/flake.lock @@ -81,7 +81,7 @@ "utils": "utils_2" }, "locked": { - "narHash": "sha256-aGpcPxOBIPnwj6uLNtpKefZjEbDkZnMHZ2mH12veHnY=", + "narHash": "sha256-LvO5VwFNFzb2xbmgw+fWhkrRY1KMlp5vxqQU/BqS0H8=", "path": "./lib", "type": "path" }, @@ -280,7 +280,7 @@ ] }, "locked": { - "narHash": "sha256-XG4TOZObj2Wd8KiqnHgtlWjjMbJOIJB7+DxUFzMCXw8=", + "narHash": "sha256-Zs7dc0dNNa0Z3//+Gckxj7SKrMqVovY0xZZ1z8xWnEg=", "path": "./pkgs", "type": "path" }, @@ -337,11 +337,11 @@ }, "utils_2": { "locked": { - "lastModified": 1618217525, - "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=", + "lastModified": 1618868421, + "narHash": "sha256-vyoJhLV6cJ8/tWz+l9HZLIkb9Rd9esE7p+0RL6zDR6Y=", "owner": "numtide", "repo": "flake-utils", - "rev": "c6169a2772643c4a93a0b5ac1c61e296cba68544", + "rev": "eed214942bcfb3a8cc09eb3b28ca7d7221e44a94", "type": "github" }, "original": { diff --git a/lib/devos/default.nix b/lib/devos/default.nix index 05ec38f..9a3118f 100644 --- a/lib/devos/default.nix +++ b/lib/devos/default.nix @@ -9,7 +9,7 @@ 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; }; diff --git a/lib/devos/devosSystem.nix b/lib/devos/devosSystem.nix index 6ea50da..c27a5a8 100644 --- a/lib/devos/devosSystem.nix +++ b/lib/devos/devosSystem.nix @@ -1,8 +1,7 @@ { lib }: -{ userFlakeNixOS, userFlakeSelf, userFlakeInputs }: - -{ modules, ... } @ args: +{ self, nixos, inputs, modules, ... } @ allArgs: +let args = builtins.removeAttrs allArgs [ "self" "nixos" "inputs" ]; in lib.nixosSystem (args // { modules = let @@ -15,7 +14,7 @@ lib.nixosSystem (args // { (args // { 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, ... }: { @@ -25,15 +24,15 @@ lib.nixosSystem (args // { disabledModules = map (x: [ x ]) (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.contents = [{ - source = userFlakeSelf; + source = self; target = "/devos/"; }]; isoImage.storeContents = [ - userFlakeSelf.devShell.${config.nixpkgs.system} + self.devShell.${config.nixpkgs.system} # include also closures that are "switched off" by the # above profile filter on the local config attribute fullHostConfig.system.build.toplevel diff --git a/lib/devos/mkHomeConfigurations.nix b/lib/devos/mkHomeConfigurations.nix index 6ccfa50..3a07ba8 100644 --- a/lib/devos/mkHomeConfigurations.nix +++ b/lib/devos/mkHomeConfigurations.nix @@ -1,6 +1,6 @@ { lib }: -{ userFlakeSelf }: +nixosConfigurations: with lib; let @@ -8,7 +8,7 @@ let mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home) config.config.system.build.homes; - hmConfigs = mapAttrs mkHomes userFlakeSelf.nixosConfigurations; + hmConfigs = mapAttrs mkHomes nixosConfigurations; in foldl recursiveUpdate { } (attrValues hmConfigs) diff --git a/lib/devos/mkHosts.nix b/lib/devos/mkHosts.nix index 3dc811e..2316da3 100644 --- a/lib/devos/mkHosts.nix +++ b/lib/devos/mkHosts.nix @@ -1,8 +1,6 @@ -{ lib }: +{ lib }: -{ userFlakeNixOS, userFlakeInputs, userFlakeSelf }: - -{ dir, extern, suites, overrides, multiPkgs }: +{ self, nixos, inputs, dir, extern, suites, overrides, multiPkgs }: let defaultSystem = "x86_64-linux"; @@ -31,24 +29,24 @@ let useUserPackages = true; 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; hardware.enableRedistributableFirmware = lib.mkDefault true; nix.nixPath = [ - "nixpkgs=${userFlakeNixOS}" - "nixos-config=${userFlakeSelf}/lib/compat/nixos" - "home-manager=${userFlakeInputs.home}" + "nixpkgs=${nixos}" + "nixos-config=${self}/lib/compat/nixos" + "home-manager=${inputs.home}" ]; nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system}; nix.registry = { - devos.flake = userFlakeSelf; - nixos.flake = userFlakeNixOS; - override.flake = userFlakeInputs.override; + devos.flake = self; + nixos.flake = nixos; + override.flake = inputs.override; }; 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`. - 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 then rootCachix else { } @@ -84,7 +82,7 @@ let networking = { inherit hostName; }; _module.args = { - self = userFlakeSelf; + self = self; hosts = builtins.mapAttrs (_: host: host.config) (removeAttrs hosts [ hostName ]); }; @@ -97,9 +95,7 @@ let }; in lib.os.devosSystem { - inherit userFlakeNixOS userFlakeInputs userFlakeSelf; - } { - inherit specialArgs; + inherit self nixos inputs specialArgs; system = defaultSystem; modules = modules // { inherit local; }; }; diff --git a/lib/devos/mkPackages.nix b/lib/devos/mkPackages.nix index eeac929..d899268 100644 --- a/lib/devos/mkPackages.nix +++ b/lib/devos/mkPackages.nix @@ -1,10 +1,7 @@ { lib }: -{ userFlakeSelf }: - -{ pkgs }: +{ overlay, overlays, pkgs }: let - inherit (userFlakeSelf) overlay overlays; packagesNames = lib.attrNames (overlay null null) ++ lib.attrNames (lib.concatAttrs (lib.attrValues diff --git a/lib/devos/mkPkgs.nix b/lib/devos/mkPkgs.nix index be32ddd..a7cf236 100644 --- a/lib/devos/mkPkgs.nix +++ b/lib/devos/mkPkgs.nix @@ -1,12 +1,10 @@ { lib, utils }: -{ userFlakeNixOS, userFlakeSelf, userFlakeInputs }: - -{ extern, overrides }: +{ self, nixos, inputs, extern, overrides }: (utils.lib.eachDefaultSystem (system: let - overridePkgs = lib.os.pkgImport userFlakeInputs.override [ ] system; + overridePkgs = lib.os.pkgImport inputs.override [ ] system; overridesOverlay = overrides.packages; overlays = [ @@ -17,11 +15,11 @@ }); }) (overridesOverlay overridePkgs) - userFlakeSelf.overlay + self.overlay ] ++ extern.overlays - ++ (lib.attrValues userFlakeSelf.overlays); + ++ (lib.attrValues self.overlays); in - { pkgs = lib.os.pkgImport userFlakeNixOS overlays system; } + { pkgs = lib.os.pkgImport nixos overlays system; } ) ).pkgs diff --git a/lib/devos/mkProfileAttrs.nix b/lib/devos/mkProfileAttrs.nix index 0a96cfb..cdfc32e 100644 --- a/lib/devos/mkProfileAttrs.nix +++ b/lib/devos/mkProfileAttrs.nix @@ -2,16 +2,16 @@ let mkProfileAttrs = /** - Synopsis: mkProfileAttrs _path_ + Synopsis: mkProfileAttrs _path_ - Recursively collect the subdirs of _path_ containing a default.nix into attrs. - This sets a contract, eliminating ambiguity for _default.nix_ living under the - profile directory. + Recursively collect the subdirs of _path_ containing a default.nix into attrs. + This sets a contract, eliminating ambiguity for _default.nix_ living under the + profile directory. - Example: - let profiles = mkProfileAttrs ./profiles; in - assert profiles ? core.default; 0 - **/ + Example: + let profiles = mkProfileAttrs ./profiles; in + assert profiles ? core.default; 0 + **/ dir: let imports = diff --git a/lib/flake.lock b/lib/flake.lock new file mode 100644 index 0000000..f70c491 --- /dev/null +++ b/lib/flake.lock @@ -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 +} diff --git a/lib/flake.nix b/lib/flake.nix index 4120e83..c9bd99a 100644 --- a/lib/flake.nix +++ b/lib/flake.nix @@ -4,87 +4,84 @@ inputs = { deploy.url = "github:serokell/deploy-rs"; - deploy.inputs = { - utils.follows = "utils"; - }; devshell.url = "github:numtide/devshell"; utils.url = "github:numtide/flake-utils"; - }; - outputs = inputs@{ self, nixpkgs, deploy, devshell, utils, ... }: let - - 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: + outputs = inputs@{ self, nixpkgs, deploy, devshell, utils, ... }: 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 + + { + inherit jobs; + + lib = utils.lib // { + inherit (lib) + mkFlake; + }; + + } + + // + + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { checks = { tests = import ./tests { - inherit (nixpkgs') pkgs; + inherit pkgs; lib = nixpkgs.lib // lib; }; }; } - ); + ); } diff --git a/lib/jobs/default.nix b/lib/jobs/default.nix index 2f108ed..5e9cff2 100644 --- a/lib/jobs/default.nix +++ b/lib/jobs/default.nix @@ -1,5 +1,7 @@ -{ nixpkgs, lib, system ? "x86_64-linux" }: let - pkgs = import nixpkgs { inherit system; overlays = []; config = {}; }; -in { +{ nixpkgs, lib, system ? "x86_64-linux" }: +let + pkgs = import nixpkgs { inherit system; overlays = [ ]; config = { }; }; +in +{ mkFlakeDoc = import ./mkFlakeDoc.nix { inherit pkgs lib; }; } diff --git a/lib/jobs/mkFlakeDoc.nix b/lib/jobs/mkFlakeDoc.nix index 45ddeed..5a13d9f 100644 --- a/lib/jobs/mkFlakeDoc.nix +++ b/lib/jobs/mkFlakeDoc.nix @@ -22,9 +22,7 @@ let ''; options = ( - lib.mkFlake.evalArgs - { userFlakeSelf = {}; userFlakeNixOS = {}; } - { args = { }; } + lib.mkFlake.evalArgs { nixos = "nixos"; args = { }; } ).options; processedOptions = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix; diff --git a/lib/mkFlake/default.nix b/lib/mkFlake/default.nix index 217baa6..d086283 100644 --- a/lib/mkFlake/default.nix +++ b/lib/mkFlake/default.nix @@ -6,31 +6,26 @@ in _: { self, inputs, nixos, ... } @ args: let - userFlakeSelf = self; - userFlakeInputs = inputs; - userFlakeNixOS = nixos; - cfg = ( lib.mkFlake.evalOldArgs - { inherit userFlakeSelf userFlakeInputs; } - { inherit args; } + { inherit self inputs args; } ).config; multiPkgs = os.mkPkgs - { inherit userFlakeSelf userFlakeInputs userFlakeNixOS; } - { inherit (cfg) extern overrides; }; + { + inherit self inputs nixos; + inherit (cfg) extern overrides; + }; outputs = { nixosConfigurations = os.mkHosts - { inherit userFlakeSelf userFlakeInputs userFlakeNixOS; } { - inherit multiPkgs; + inherit self inputs nixos multiPkgs; inherit (cfg) extern suites overrides; dir = cfg.hosts; }; - homeConfigurations = os.mkHomeConfigurations - { inherit userFlakeSelf; }; + homeConfigurations = os.mkHomeConfigurations self.nixosConfigurations; nixosModules = cfg.modules; @@ -39,7 +34,7 @@ let overlay = cfg.packages; inherit (cfg) overlays; - deploy.nodes = os.mkNodes deploy userFlakeSelf.nixosConfigurations; + deploy.nodes = os.mkNodes deploy self.nixosConfigurations; }; systemOutputs = lib.eachDefaultSystem (system: @@ -47,15 +42,16 @@ let pkgs = multiPkgs.${system}; pkgs-lib = lib.pkgs-lib.${system}; # all packages that are defined in ./pkgs - legacyPackages = os.mkPackages - { inherit userFlakeSelf; } - { inherit pkgs; }; + legacyPackages = os.mkPackages { + inherit pkgs; + inherit (self) overlay overlays; + }; in { checks = pkgs-lib.tests.mkChecks { - inherit (userFlakeSelf.deploy) nodes; - hosts = userFlakeSelf.nixosConfigurations; - homes = userFlakeSelf.homeConfigurations; + inherit (self.deploy) nodes; + hosts = self.nixosConfigurations; + homes = self.homeConfigurations; }; inherit legacyPackages; diff --git a/lib/mkFlake/evalArgs.nix b/lib/mkFlake/evalArgs.nix index b162ad1..cb90f61 100644 --- a/lib/mkFlake/evalArgs.nix +++ b/lib/mkFlake/evalArgs.nix @@ -1,8 +1,6 @@ { lib }: -{ userFlakeSelf, userFlakeNixOS }: - -{ args }: +{ nixos, args }: let argOpts = with lib; { config, ... }: let @@ -51,10 +49,10 @@ let options = with types; { input = mkOption { type = flakeType; - default = userFlakeNixOS; + default = nixos; description = '' nixpkgs flake input to use for this channel - ''; + ''; }; overlays = mkOption { type = pathToListOf overlayType; @@ -198,7 +196,7 @@ let let default = { nixpkgs = { - input = userFlakeNixOS; + input = nixos; }; }; in diff --git a/lib/mkFlake/evalOldArgs.nix b/lib/mkFlake/evalOldArgs.nix index 2cf9221..c319d43 100644 --- a/lib/mkFlake/evalOldArgs.nix +++ b/lib/mkFlake/evalOldArgs.nix @@ -1,8 +1,6 @@ { lib }: -{ userFlakeSelf, userFlakeInputs }: - -{ args }: +{ self, inputs, args }: let argOpts = with lib; { config, options, ... }: let @@ -32,8 +30,8 @@ let }; hosts = mkOption { type = path; - default = "${userFlakeSelf}/hosts"; - defaultText = "\${userFlakeSelf}/hosts"; + default = "${self}/hosts"; + defaultText = "\${self}/hosts"; apply = toString; description = '' Path to directory containing host configurations that will be exported @@ -74,15 +72,15 @@ let }; profiles = mkOption { type = path; - default = "${userFlakeSelf}/profiles"; - defaultText = "\${userFlakeSelf}/profiles"; + default = "${self}/profiles"; + defaultText = "\${self}/profiles"; apply = x: os.mkProfileAttrs (toString x); description = "path to profiles folder that can be collected into suites"; }; userProfiles = mkOption { type = path; - default = "${userFlakeSelf}/users/profiles"; - defaultText = "\${userFlakeSelf}/users/profiles"; + default = "${self}/users/profiles"; + defaultText = "\${self}/users/profiles"; apply = x: os.mkProfileAttrs (toString x); description = "path to user profiles folder that can be collected into userSuites"; }; @@ -107,8 +105,8 @@ let }; users = mkOption { type = path; - default = "${userFlakeSelf}/users"; - defaultText = "\${userFlakeSelf}/users"; + default = "${self}/users"; + defaultText = "\${self}/users"; apply = x: os.mkProfileAttrs (toString x); description = '' path to folder containing profiles that define system users @@ -131,9 +129,9 @@ let { modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; } ''; # 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 = '' - 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 specialArgs to be included across nixos and home manager configurations. Only attributes that are used should be returned. @@ -141,8 +139,8 @@ let }; overlays = mkOption { type = path; - default = "${userFlakeSelf}/overlays"; - defaultText = "\${userFlakeSelf}/overlays"; + default = "${self}/overlays"; + defaultText = "\${self}/overlays"; apply = x: lib.pathsToImportedAttrs (lib.pathsIn (toString x)); description = '' path to folder containing overlays which will be applied to pkgs and exported in diff --git a/lib/pkgs-lib/default.nix b/lib/pkgs-lib/default.nix index 40b451c..1cadc2f 100644 --- a/lib/pkgs-lib/default.nix +++ b/lib/pkgs-lib/default.nix @@ -1,9 +1,13 @@ { lib, nixpkgs, deploy, devshell }: 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; }; } ) diff --git a/lib/pkgs-lib/shell/default.nix b/lib/pkgs-lib/shell/default.nix index 7744f68..0146ca2 100644 --- a/lib/pkgs-lib/shell/default.nix +++ b/lib/pkgs-lib/shell/default.nix @@ -11,7 +11,7 @@ let ]; - pkgs = import nixpkgs { inherit system overlays; config = {}; }; + pkgs = import nixpkgs { inherit system overlays; config = { }; }; flk = pkgs.callPackage ./flk.nix { }; diff --git a/lib/pkgs-lib/tests/default.nix b/lib/pkgs-lib/tests/default.nix index 6111acd..b3e6062 100644 --- a/lib/pkgs-lib/tests/default.nix +++ b/lib/pkgs-lib/tests/default.nix @@ -1,7 +1,5 @@ -{ lib, nixpkgs, deploy, system }: +{ lib, nixpkgs, pkgs, deploy, system }: let - pkgs = import nixpkgs { inherit system; overlays = []; config = {}; }; - mkChecks = { hosts, nodes, homes ? { } }: let deployHosts = lib.filterAttrs @@ -9,9 +7,10 @@ let nodes; deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; }; tests = - lib.optionalAttrs (deployHosts != { }) { - profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))}); - } // lib.mapAttrs (n: v: v.activationPackage) homes; + lib.optionalAttrs (deployHosts != { }) + { + profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))}); + } // lib.mapAttrs (n: v: v.activationPackage) homes; in lib.recursiveUpdate tests deployChecks; diff --git a/lib/tests/default.nix b/lib/tests/default.nix index 4863cdf..ab4d516 100644 --- a/lib/tests/default.nix +++ b/lib/tests/default.nix @@ -1,27 +1,27 @@ { pkgs, lib }: pkgs.runCommandNoCC "devos-lib-tests" - { - buildInputs = [ - pkgs.nix - ( - let tests = import ./lib.nix { inherit pkgs lib; }; in - if tests == [ ] then null - else throw (builtins.toJSON tests) - ) - ]; - } '' - datadir="${pkgs.nix}/share" - export TEST_ROOT=$(pwd)/test-tmp - export NIX_BUILD_HOOK= - export NIX_CONF_DIR=$TEST_ROOT/etc - export NIX_LOCALSTATE_DIR=$TEST_ROOT/var - export NIX_LOG_DIR=$TEST_ROOT/var/log/nix - export NIX_STATE_DIR=$TEST_ROOT/var/nix - export NIX_STORE_DIR=$TEST_ROOT/store - export PAGER=cat - cacheDir=$TEST_ROOT/binary-cache - nix-store --init +{ + buildInputs = [ + pkgs.nix + ( + let tests = import ./lib.nix { inherit pkgs lib; }; in + if tests == [ ] then null + else throw (builtins.toJSON tests) + ) + ]; +} '' + datadir="${pkgs.nix}/share" + export TEST_ROOT=$(pwd)/test-tmp + export NIX_BUILD_HOOK= + export NIX_CONF_DIR=$TEST_ROOT/etc + export NIX_LOCALSTATE_DIR=$TEST_ROOT/var + export NIX_LOG_DIR=$TEST_ROOT/var/log/nix + export NIX_STATE_DIR=$TEST_ROOT/var/nix + export NIX_STORE_DIR=$TEST_ROOT/store + export PAGER=cat + cacheDir=$TEST_ROOT/binary-cache + nix-store --init - touch $out - '' + touch $out +''