diff --git a/flake.nix b/flake.nix index ce87ac5d0..4f5d3564b 100644 --- a/flake.nix +++ b/flake.nix @@ -31,29 +31,30 @@ outputs = inputs@{ deploy, nixos, nur, self, utils, ... }: let lib = import ./lib { inherit self nixos inputs; }; - in - lib.mkFlake { - inherit self; - hosts = ./hosts; - packages = import ./pkgs; - suites = import ./suites; - extern = import ./extern; - overrides = import ./overrides; - overlays = ./overlays; - profiles = ./profiles; - userProfiles = ./users/profiles; - modules = import ./modules/module-list.nix; - userModules = import ./users/modules/module-list.nix; - } // { - defaultTemplate = self.templates.flk; - templates.flk.path = ./.; - templates.flk.description = "flk template"; - templates.mkflake.path = - let - excludes = [ "lib" "tests" "cachix" "nix" "theme" ".github" "bors.toml" "cachix.nix" ]; - filter = path: type: ! builtins.elem (baseNameOf path) excludes; - in - builtins.filterSource filter ./.; - templates.mkflake.description = "template with necessary folders for mkFlake usage"; - }; + in lib.mkFlake { + inherit self; + hosts = ./hosts; + packages = import ./pkgs; + suites = import ./suites; + extern = import ./extern; + overrides = import ./overrides; + overlays = ./overlays; + profiles = ./profiles; + userProfiles = ./users/profiles; + modules = import ./modules/module-list.nix; + userModules = import ./users/modules/module-list.nix; + } // { + inherit lib; + defaultTemplate = self.templates.flk; + templates.flk.path = ./.; + templates.flk.description = "flk template"; + templates.mkflake.path = + let + excludes = [ "lib" "tests" "cachix" "nix" "theme" ".github" "bors.toml" "cachix.nix" ]; + filter = path: type: ! builtins.elem (baseNameOf path) excludes; + in + builtins.filterSource filter ./.; + templates.mkflake.description = "template with necessary folders for mkFlake usage"; + }; + } diff --git a/lib/default.nix b/lib/default.nix index b9a7a5071..a44613b79 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,14 +1,10 @@ -args@{ nixos, self, ... }: -let inherit (nixos) lib; in -lib.makeExtensible (final: - let callLibs = file: import file - ({ - inherit lib; - - dev = final; - } // args); +args@{ nixos, self, ... }: # TODO: craft well-defined api for devos-lib +let + inherit (nixos) lib; +in lib.makeExtensible (final: + let + callLibs = file: import file ({ lib = final; } // args); in - with final; { inherit callLibs; @@ -18,8 +14,8 @@ lib.makeExtensible (final: strings = callLibs ./strings.nix; mkFlake = callLibs ./mkFlake; - evalFlakeArgs = callLibs ./mkFlake/evalArgs.nix; - + } // + with final; { inherit (attrs) mapFilterAttrs genAttrs' safeReadDir pathsToImportedAttrs concatAttrs filterPackages; inherit (lists) pathsIn; diff --git a/lib/devos/default.nix b/lib/devos/default.nix index e580ef005..fb9e990f1 100644 --- a/lib/devos/default.nix +++ b/lib/devos/default.nix @@ -1,4 +1,4 @@ -{ lib, nixos, dev, ... }: +{ lib, ... }: { # pkgImport :: Nixpkgs -> Overlays -> System -> Pkgs pkgImport = nixpkgs: overlays: system: @@ -9,22 +9,22 @@ profileMap = map (profile: profile.default); - mkNodes = dev.callLibs ./mkNodes.nix; + mkNodes = lib.callLibs ./mkNodes.nix; - mkHosts = dev.callLibs ./mkHosts.nix; + mkHosts = lib.callLibs ./mkHosts.nix; - mkSuites = dev.callLibs ./mkSuites.nix; + mkSuites = lib.callLibs ./mkSuites.nix; - mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix; + mkProfileAttrs = lib.callLibs ./mkProfileAttrs.nix; - mkPkgs = dev.callLibs ./mkPkgs.nix; + mkPkgs = lib.callLibs ./mkPkgs.nix; - recImport = dev.callLibs ./recImport.nix; + recImport = lib.callLibs ./recImport.nix; - devosSystem = dev.callLibs ./devosSystem.nix; + devosSystem = lib.callLibs ./devosSystem.nix; - mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix; + mkHomeConfigurations = lib.callLibs ./mkHomeConfigurations.nix; - mkPackages = dev.callLibs ./mkPackages.nix; + mkPackages = lib.callLibs ./mkPackages.nix; } diff --git a/lib/devos/mkHosts.nix b/lib/devos/mkHosts.nix index e0c7ea477..032d262b0 100644 --- a/lib/devos/mkHosts.nix +++ b/lib/devos/mkHosts.nix @@ -1,6 +1,6 @@ -{ lib, dev, nixos, inputs, self, ... }: +{ lib, nixos, inputs, ... }: -{ dir, devos, extern, suites, overrides, multiPkgs, ... }: +{ self, dir, extern, suites, overrides, multiPkgs, ... }: let defaultSystem = "x86_64-linux"; @@ -44,7 +44,7 @@ let nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system}; nix.registry = { - devos.flake = self; + self.flake = self; nixos.flake = nixos; override.flake = inputs.override; }; @@ -61,7 +61,7 @@ let # Everything in `./modules/list.nix`. flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; }; - cachix = "${devos}/cachix.nix"; + cachix = "${self}/cachix.nix"; }; specialArgs = extern.specialArgs // { suites = suites.system; }; @@ -88,13 +88,13 @@ let }; }; in - dev.os.devosSystem { + lib.os.devosSystem { inherit specialArgs; system = defaultSystem; modules = modules // { inherit local lib; }; }; - hosts = dev.os.recImport + hosts = lib.os.recImport { inherit dir; _import = mkHostConfig; diff --git a/lib/devos/mkPackages.nix b/lib/devos/mkPackages.nix index a876ea0b7..0aebb7ebf 100644 --- a/lib/devos/mkPackages.nix +++ b/lib/devos/mkPackages.nix @@ -1,10 +1,10 @@ -{ lib, dev, self, ... }: +{ lib, self, ... }: { pkgs }: let inherit (self) overlay overlays; packagesNames = lib.attrNames (overlay null null) - ++ lib.attrNames (dev.concatAttrs + ++ lib.attrNames (lib.concatAttrs (lib.attrValues (lib.mapAttrs (_: v: v null null) overlays) ) diff --git a/lib/devos/mkPkgs.nix b/lib/devos/mkPkgs.nix index f3126eaff..4eb709b6a 100644 --- a/lib/devos/mkPkgs.nix +++ b/lib/devos/mkPkgs.nix @@ -1,27 +1,19 @@ -{ lib, dev, nixos, self, inputs, ... }: +{ lib, nixos, self, inputs, ... }: { extern, overrides }: (inputs.utils.lib.eachDefaultSystem (system: let - overridePkgs = dev.os.pkgImport inputs.override [ ] system; + overridePkgs = lib.os.pkgImport inputs.override [ ] system; overridesOverlay = overrides.packages; overlays = [ - (final: prev: { - lib = prev.lib.extend (lfinal: lprev: { - inherit dev; - inherit (lib) nixosSystem; - - utils = inputs.utils.lib; - }); - }) (overridesOverlay overridePkgs) self.overlay ] ++ extern.overlays ++ (lib.attrValues self.overlays); in - { pkgs = dev.os.pkgImport nixos overlays system; } + { pkgs = lib.os.pkgImport nixos overlays system; } ) ).pkgs diff --git a/lib/devos/mkProfileAttrs.nix b/lib/devos/mkProfileAttrs.nix index d89c6ba22..7168b2910 100644 --- a/lib/devos/mkProfileAttrs.nix +++ b/lib/devos/mkProfileAttrs.nix @@ -1,4 +1,4 @@ -{ lib, dev, ... }: +{ lib, ... }: let mkProfileAttrs = /** @@ -16,7 +16,7 @@ let mkProfileAttrs = let imports = let - files = dev.safeReadDir dir; + files = lib.safeReadDir dir; p = n: v: v == "directory" diff --git a/lib/devos/mkSuites.nix b/lib/devos/mkSuites.nix index a3a329440..7adb7c889 100644 --- a/lib/devos/mkSuites.nix +++ b/lib/devos/mkSuites.nix @@ -1,8 +1,7 @@ -{ lib, dev, ... }: +{ lib, ... }: { users, profiles, userProfiles, suites } @ args: let - inherit (dev) os; definedSuites = suites { inherit (args) users profiles userProfiles; @@ -16,7 +15,7 @@ let let defaults = lib.collect (x: x ? default) users; in map (x: x.default) defaults; - createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // { + createSuites = _: suites: lib.mapAttrs (_: v: lib.os.profileMap v) suites // { inherit allProfiles allUsers; }; diff --git a/lib/devos/recImport.nix b/lib/devos/recImport.nix index d7f2aa82b..66a818c4a 100644 --- a/lib/devos/recImport.nix +++ b/lib/devos/recImport.nix @@ -1,7 +1,7 @@ -{ lib, dev, ... }: +{ lib, ... }: { dir, _import ? base: import "${dir}/${base}.nix" }: -dev.mapFilterAttrs +lib.mapFilterAttrs (_: v: v != null) (n: v: if n != "default.nix" && lib.hasSuffix ".nix" n && v == "regular" @@ -9,4 +9,4 @@ dev.mapFilterAttrs let name = lib.removeSuffix ".nix" n; in lib.nameValuePair (name) (_import name) else lib.nameValuePair ("") (null)) - (dev.safeReadDir dir) + (lib.safeReadDir dir) diff --git a/lib/lists.nix b/lib/lists.nix index b6530f133..74cf9bd4b 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -1,8 +1,8 @@ -{ lib, dev, ... }: +{ lib, ... }: { pathsIn = dir: let fullPath = name: "${toString dir}/${name}"; in - map fullPath (lib.attrNames (dev.safeReadDir dir)); + map fullPath (lib.attrNames (lib.safeReadDir dir)); } diff --git a/lib/mkFlake/default.nix b/lib/mkFlake/default.nix index cca6ccdf5..300445e55 100644 --- a/lib/mkFlake/default.nix +++ b/lib/mkFlake/default.nix @@ -1,22 +1,20 @@ -{ self, nixos, inputs, ... }: +{ lib, inputs, ... }: let - devos = self; + inherit (lib) os; # TODO: find a more approriate naming scheme + inherit (inputs) utils deploy; # TODO: make this direct inputs of future devos-lib flake + evalFlakeArgs = lib.callLibs ./evalArgs.nix; in { self, ... } @ args: let - inherit (self) lib; - inherit (lib) os; - inherit (inputs) utils deploy; - - cfg = (lib.evalFlakeArgs { inherit args; }).config; + cfg = (evalFlakeArgs { inherit args; }).config; multiPkgs = os.mkPkgs { inherit (cfg) extern overrides; }; outputs = { nixosConfigurations = os.mkHosts { - inherit devos multiPkgs; + inherit self multiPkgs; inherit (cfg) extern suites overrides; dir = cfg.hosts; }; @@ -30,11 +28,6 @@ let overlay = cfg.packages; inherit (cfg) overlays; - lib = import "${devos}/lib" { - inherit self nixos; - inputs = inputs // self.inputs; - }; - deploy.nodes = os.mkNodes deploy self.nixosConfigurations; }; @@ -48,7 +41,7 @@ let checks = let tests = nixos.lib.optionalAttrs (system == "x86_64-linux") - (import "${devos}/tests" { inherit pkgs; self = devos; }); + (import "${self}/tests" { inherit self pkgs; }); deployHosts = nixos.lib.filterAttrs (n: _: self.nixosConfigurations.${n}.config.nixpkgs.system == system) self.deploy.nodes; deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; }; @@ -58,10 +51,10 @@ let inherit legacyPackages; packages = lib.filterPackages system legacyPackages; - devShell = import "${devos}/shell" { + devShell = import "${self}/shell" { inherit self system; }; }); in - nixos.lib.recursiveUpdate outputs systemOutputs + outputs // systemOutputs diff --git a/lib/mkFlake/evalArgs.nix b/lib/mkFlake/evalArgs.nix index 69cc665cc..de8a8692b 100644 --- a/lib/mkFlake/evalArgs.nix +++ b/lib/mkFlake/evalArgs.nix @@ -1,11 +1,9 @@ -{ self, dev, nixos, inputs, ... }: +{ self, lib, inputs, ... }: { args }: let - argOpts = with nixos.lib; { config, options, ... }: + argOpts = with lib; { config, options, ... }: let - inherit (dev) os; - inherit (config) self; inputAttrs = with types; functionTo attrs; @@ -17,7 +15,7 @@ let { options = with types; { self = mkOption { - type = addCheck attrs nixos.lib.isStorePath; + type = addCheck attrs isStorePath; description = "The flake to create the devos outputs for"; }; hosts = mkOption { @@ -48,7 +46,7 @@ let modules = mkOption { type = listOf moduleType; default = []; - apply = dev.pathsToImportedAttrs; + apply = pathsToImportedAttrs; description = '' list of modules to include in confgurations and export in 'nixosModules' output ''; @@ -56,7 +54,7 @@ let userModules = mkOption { type = listOf moduleType; default = []; - apply = dev.pathsToImportedAttrs; + apply = pathsToImportedAttrs; description = '' list of modules to include in home-manager configurations and export in 'homeModules' output @@ -130,7 +128,7 @@ let type = path; default = "${self}/overlays"; defaultText = "\${self}/overlays"; - apply = x: dev.pathsToImportedAttrs (dev.pathsIn (toString x)); + apply = x: pathsToImportedAttrs (pathsIn (toString x)); description = '' path to folder containing overlays which will be applied to pkgs and exported in the 'overlays' output @@ -143,40 +141,9 @@ let apply = x: default // x; description = "attrset of packages and modules that will be pulled from nixpkgs master"; }; - genDoc = mkOption { - type = functionTo attrs; - internal = true; - description = "function that returns a generated options doc derivation given nixpkgs"; - }; }; - config.genDoc = - let - singleDoc = name: value: '' - ## ${name} - ${value.description} - - ${optionalString (value ? type) '' - *_Type_*: - ${value.type} - ''} - ${optionalString (value ? default) '' - *_Default_* - ``` - ${builtins.toJSON value.default} - ``` - ''} - ${optionalString (value ? example) '' - *_Example_* - ``` - ${value.example} - ``` - ''} - ''; - in - pkgs: with pkgs; writeText "devosOptions.md" - (concatStringsSep "" (mapAttrsToList singleDoc (nixosOptionsDoc { inherit options; }).optionsNix)); }; in - nixos.lib.evalModules { + lib.evalModules { modules = [ argOpts args ]; } diff --git a/pkgs/default.nix b/pkgs/default.nix index c53578234..45a4a07c5 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,3 +1,2 @@ final: prev: { - devosOptionsDoc = (prev.lib.dev.evalFlakeArgs { args = {}; }).config.genDoc prev; }