From 228dfe4ab48689281ec5e603242e50d52330d568 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Mon, 20 Nov 2023 10:36:20 +0000 Subject: fixup --- flake.nix | 9 ++++-- ivi/default.nix | 21 ++++++++++++++ ivi/ivi.nix | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/default.nix | 21 -------------- lib/ivi.nix | 83 ----------------------------------------------------- 5 files changed, 116 insertions(+), 106 deletions(-) create mode 100644 ivi/default.nix create mode 100644 ivi/ivi.nix delete mode 100644 lib/default.nix delete mode 100644 lib/ivi.nix diff --git a/flake.nix b/flake.nix index ea6cb06..6c6f0e7 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ let system = "x86_64-linux"; pkgs = import nixpkgs {inherit system;}; - lib = (nixpkgs.lib.extend (_: _: home-manager.lib)).extend (import ./lib self); + lib = (nixpkgs.lib.extend (_: _: home-manager.lib)).extend (import ./ivi self); # Gets module from ./machines/ and uses the lib to define which other modules # the machine needs. @@ -31,7 +31,7 @@ let machine = ivi.machines.${name}; in - lib.nixosSystem { + nixosSystem { inherit lib system; specialArgs = {inherit machine inputs;}; modules = with lib; @@ -50,6 +50,11 @@ nixosConfigurations = with lib; mapAttrs mkSystem (modulesIn ./machines); + nixosConfigurations.wsl = modules: + nixosSystem "wsl" ({...}: { + imports = modules; + }); + deploy.nodes = mapAttrs (hostname: machine: { diff --git a/ivi/default.nix b/ivi/default.nix new file mode 100644 index 0000000..7b80611 --- /dev/null +++ b/ivi/default.nix @@ -0,0 +1,21 @@ +self: lib: prev: with lib; { + modulesIn = dir: pipe dir [ + builtins.readDir + (mapAttrsToList (name: type: + if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then + [ { name = removeSuffix ".nix" name; value = dir + "/${name}"; } ] + else if type == "directory" && pathExists (dir + "/${name}/default.nix") then + [ { inherit name; value = dir + "/${name}"; } ] + else + [] + )) + concatLists + listToAttrs + ]; + + # Collects the inputs of a flake recursively (with possible duplicates). + collectFlakeInputs = input: + [ input ] ++ concatMap collectFlakeInputs (builtins.attrValues (input.inputs or {})); + + ivi = import ./ivi.nix self lib; +} diff --git a/ivi/ivi.nix b/ivi/ivi.nix new file mode 100644 index 0000000..f7cc0d0 --- /dev/null +++ b/ivi/ivi.nix @@ -0,0 +1,88 @@ +self: lib: with lib; let + modules = [ + { + options.machines = mkOption { + description = "Lookup for static info needed to configure machines"; + default = {}; + type = with types; attrsOf (submodule ({ name, config, ... }: { + freeformType = attrs; + options = { + modules = mkOption { + description = "Final list of modules to import"; + type = listOf str; + default = []; + }; + profiles = mkOption { + description = "List of profiles to use"; + type = listOf str; + default = []; + }; + hostname = mkOption { + description = "The machine's hostname"; + type = str; + readOnly = true; + default = name; + }; + ipv4 = mkOption { + description = "The machines public IPv4 addresses"; + type = listOf str; + default = []; + }; + ipv6 = mkOption { + description = "The machines public IPv6 addresses"; + type = listOf str; + default = []; + }; + isDeployed = mkOption { + description = "The machine is deployed with nixos"; + type = bool; + default = false; + }; + }; + config = { + modules = + (concatMap + (p: (attrValues (modulesIn (self + "/profiles/" + p)))) + ivi.machines.${name}.profiles + ); + }; + })); + }; + config = { + _module.freeformType = with types; attrs; + + username = "ivi"; + githubUsername = "ivi-vink"; + realName = "Mike Vink"; + domain = "vinkies.net"; + email = "ivi@vinkies.net"; + sshKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMT59Kbv+rO0PvB1q5u3l9wdUgsKT0M8vQ7WHnjq+kYN ${ivi.email}" + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDqsfYS7sOLfLWvGTmxT2QYGkbXJ5kREFl42n3jtte5sLps76KECgKqEjA4OLhNZ51lKFBDzcn1QOUl3RN4+qHsBtkr+02a7hhf1bBLeb1sx6+FVXdsarln5lUF/NMcpj6stUi8mqY4aQ21jQKxZsGip9fI8fx3HtXYCVhIarRbshQlwDqTplJBLDtrnmWTprxVnz1xSZRr3euXsIh1FFQZI6klPPBa6qFJtWWtGNBCRr8Sruo6I4on7QjNyW/s1OgiNAR0N2IO9wCdjlXrjNnFEAaMrpDpZde7eULbiFP2pHYVVy/InwNhhePYkeBh/4BzlaUZVv6gXsX7wOC5OyWaXbbMzWEopbnqeXXLwNyOZ88YpN/c+kZk2/1CHl+xmlVGAr9TnZ9VST5Y4ZAEqq8OKoP3ZcchAWxWjzTgPogSfiIAP/n5xrgB+8uRZb/gkN+I7RTQKGrS2Ex7gfkj39beDeevQj3XVQ1U2kp3n+jUBHItCCpZyHISgTYW2Ct6lrziJpD0kPlAOrN3BGQtkStHYK+4EE1PrrwWGkG7Ue+tlETe8FTg+AMv1VjLV9b3pHZJCrao5/cY2MxkfGzf4HTfeueqSLSsrYuiogHAPvvzfvOV5un+dWX8HyeBjmKTBwDBFuhdca/wzk0ArHSgEYUmh2NXj/G4gaSF3EX5ZSxmMQ== ${ivi.email}" + ]; + + machines = { + lemptop = { + profiles = [ + "core" + "station" + "email" + ]; + }; + wsl = { + profiles = [ + "core" + ]; + }; + serber = { + isDeployed = true; + profiles = [ + "core" + "server" + ]; + }; + }; + }; + } + ]; +in (evalModules { inherit modules; }).config diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index 7b80611..0000000 --- a/lib/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -self: lib: prev: with lib; { - modulesIn = dir: pipe dir [ - builtins.readDir - (mapAttrsToList (name: type: - if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then - [ { name = removeSuffix ".nix" name; value = dir + "/${name}"; } ] - else if type == "directory" && pathExists (dir + "/${name}/default.nix") then - [ { inherit name; value = dir + "/${name}"; } ] - else - [] - )) - concatLists - listToAttrs - ]; - - # Collects the inputs of a flake recursively (with possible duplicates). - collectFlakeInputs = input: - [ input ] ++ concatMap collectFlakeInputs (builtins.attrValues (input.inputs or {})); - - ivi = import ./ivi.nix self lib; -} diff --git a/lib/ivi.nix b/lib/ivi.nix deleted file mode 100644 index 8fabf1b..0000000 --- a/lib/ivi.nix +++ /dev/null @@ -1,83 +0,0 @@ -self: lib: with lib; let - modules = [ - { - options.machines = mkOption { - description = "Lookup for static info needed to configure machines"; - default = {}; - type = with types; attrsOf (submodule ({ name, config, ... }: { - freeformType = attrs; - options = { - modules = mkOption { - description = "Final list of modules to import"; - type = listOf str; - default = []; - }; - profiles = mkOption { - description = "List of profiles to use"; - type = listOf str; - default = []; - }; - hostname = mkOption { - description = "The machine's hostname"; - type = str; - readOnly = true; - default = name; - }; - ipv4 = mkOption { - description = "The machines public IPv4 addresses"; - type = listOf str; - default = []; - }; - ipv6 = mkOption { - description = "The machines public IPv6 addresses"; - type = listOf str; - default = []; - }; - isDeployed = mkOption { - description = "The machine is deployed with nixos"; - type = bool; - default = false; - }; - }; - config = { - modules = - (concatMap - (p: (attrValues (modulesIn (self + "/profiles/" + p)))) - ivi.machines.${name}.profiles - ); - }; - })); - }; - config = { - _module.freeformType = with types; attrs; - - username = "ivi"; - githubUsername = "ivi-vink"; - realName = "Mike Vink"; - domain = "vinkies.net"; - email = "ivi@vinkies.net"; - sshKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMT59Kbv+rO0PvB1q5u3l9wdUgsKT0M8vQ7WHnjq+kYN ${ivi.email}" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDqsfYS7sOLfLWvGTmxT2QYGkbXJ5kREFl42n3jtte5sLps76KECgKqEjA4OLhNZ51lKFBDzcn1QOUl3RN4+qHsBtkr+02a7hhf1bBLeb1sx6+FVXdsarln5lUF/NMcpj6stUi8mqY4aQ21jQKxZsGip9fI8fx3HtXYCVhIarRbshQlwDqTplJBLDtrnmWTprxVnz1xSZRr3euXsIh1FFQZI6klPPBa6qFJtWWtGNBCRr8Sruo6I4on7QjNyW/s1OgiNAR0N2IO9wCdjlXrjNnFEAaMrpDpZde7eULbiFP2pHYVVy/InwNhhePYkeBh/4BzlaUZVv6gXsX7wOC5OyWaXbbMzWEopbnqeXXLwNyOZ88YpN/c+kZk2/1CHl+xmlVGAr9TnZ9VST5Y4ZAEqq8OKoP3ZcchAWxWjzTgPogSfiIAP/n5xrgB+8uRZb/gkN+I7RTQKGrS2Ex7gfkj39beDeevQj3XVQ1U2kp3n+jUBHItCCpZyHISgTYW2Ct6lrziJpD0kPlAOrN3BGQtkStHYK+4EE1PrrwWGkG7Ue+tlETe8FTg+AMv1VjLV9b3pHZJCrao5/cY2MxkfGzf4HTfeueqSLSsrYuiogHAPvvzfvOV5un+dWX8HyeBjmKTBwDBFuhdca/wzk0ArHSgEYUmh2NXj/G4gaSF3EX5ZSxmMQ== ${ivi.email}" - ]; - - machines = { - lemptop = { - profiles = [ - "core" - "station" - "email" - ]; - }; - serber = { - isDeployed = true; - profiles = [ - "core" - "server" - ]; - }; - }; - }; - } - ]; -in (evalModules { inherit modules; }).config -- cgit v1.2.3