Import overhaul!

This commit is contained in:
kat witch 2021-08-18 00:31:04 +01:00
parent 1e53ee9d2e
commit 8a32942d0e
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
16 changed files with 95 additions and 93 deletions

View file

@ -20,7 +20,7 @@ let
filterAttrNamesToList = filter: set: filterAttrNamesToList = filter: set:
lib.foldl' (a: b: a ++ b) [ ] lib.foldl' (a: b: a ++ b) [ ]
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (lib.attrNames set)); (map (e: if (filter e set.${e}) then [ e ] else [ ]) (lib.attrNames set));
depotNames = lib.unique (lib.folderList ./depot ["trusted"] ++ lib.folderList ./depot/trusted ["pkgs"]); depotNames = lib.unique (lib.folderList ./depot ["trusted"] ++ lib.folderList ./depot/trusted ["pkgs" "tf"]);
depot = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge { depot = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge {
inherit folder; inherit folder;
folderPaths = [ (./depot + "/${folder}") (./depot/trusted + "/${folder}") ]; folderPaths = [ (./depot + "/${folder}") (./depot/trusted + "/${folder}") ];
@ -64,5 +64,5 @@ let
* do not use common, it is tf-nix specific config ingested at line 66 of config/modules/meta/deploy.nix for every target. * do not use common, it is tf-nix specific config ingested at line 66 of config/modules/meta/deploy.nix for every target.
* services -> the specialArg generated from services/ * services -> the specialArg generated from services/
*/ */
self = config // { inherit pkgs lib sourceCache sources; } // depot; self = config // { inherit pkgs lib sourceCache sources; } // depot;
in self in self

View file

@ -1,25 +1,17 @@
{ profiles, lib, root, config, ... }: with lib; { { config, lib, kw, ... }: with lib; {
config = { deploy.targets.infra = {
deploy.targets.infra = { tf = {
tf = { resources.athame = {
resources.athame = { provider = "null";
provider = "null"; type = "resource";
type = "resource"; connection = {
connection = { port = head config.network.nodes.athame.services.openssh.ports;
port = 62954; host = config.network.nodes.athame.network.addresses.public.ipv4.address;
host = config.network.nodes.athame.network.addresses.public.ipv4.address;
};
}; };
}; };
}; };
network.nodes.athame = { };
imports = lib.hostImport { network.nodes.athame = {
hostName = "athame"; imports = kw.nodeImport "athame";
inherit profiles root;
};
networking = {
hostName = "athame";
};
};
}; };
} }

View file

@ -1,4 +1,4 @@
{ profiles, config, root, lib, ... }: with lib; { { config, lib, kw, ... }: with lib; {
config = { config = {
deploy.targets.beltane = { deploy.targets.beltane = {
tf = { tf = {
@ -6,20 +6,14 @@
provider = "null"; provider = "null";
type = "resource"; type = "resource";
connection = { connection = {
port = 62954; port = head config.network.nodes.beltane.services.openssh.ports;
host = config.network.nodes.beltane.network.addresses.private.ipv4.address; host = config.network.nodes.beltane.network.addresses.private.ipv4.address;
}; };
}; };
}; };
}; };
network.nodes.beltane = { network.nodes.beltane = {
imports = lib.hostImport { imports = kw.nodeImport "beltane";
hostName = "beltane";
inherit profiles root;
};
networking = {
hostName = "beltane";
};
}; };
}; };
} }

View file

@ -1,11 +1,7 @@
{ lib, config, root, profiles, ... }: with lib; { { config, lib, kw, ... }: with lib; {
deploy.targets.dummy.enable = false; deploy.targets.dummy.enable = false;
network.nodes.dummy = { network.nodes.dummy = {
imports = lib.hostImport { imports = kw.nodeImport {
hostName = "dummy";
inherit profiles root;
};
networking = {
hostName = "dummy"; hostName = "dummy";
}; };
}; };

View file

@ -1,4 +1,4 @@
{ meta, profiles, root, config, lib, ... }: with lib; { { config, lib, kw, ... }: with lib; {
config = { config = {
deploy.targets.ostara = { deploy.targets.ostara = {
tf = { tf = {
@ -6,20 +6,14 @@
provider = "null"; provider = "null";
type = "resource"; type = "resource";
connection = { connection = {
port = 62954; port = head config.network.nodes.ostara.services.openssh.ports;
host = meta.network.nodes.ostara.network.addresses.private.ipv4.address; host = config.network.nodes.ostara.network.addresses.private.ipv4.address;
}; };
}; };
}; };
}; };
network.nodes.ostara = { network.nodes.ostara = {
imports = lib.hostImport { imports = kw.nodeImport "ostara";
hostName = "ostara";
inherit profiles root;
};
networking = {
hostName = "ostara";
};
}; };
}; };
} }

View file

@ -36,6 +36,7 @@ with lib;
# Networking # Networking
networking = { networking = {
hostName = "ostara";
hostId = "9f89b327"; hostId = "9f89b327";
useDHCP = false; useDHCP = false;
interfaces.enp1s0.ipv4.addresses = singleton { interfaces.enp1s0.ipv4.addresses = singleton {

View file

@ -1,4 +1,4 @@
{ lib, config, root, profiles, ... }: with lib; { { config, lib, kw, ... }: with lib; {
config = { config = {
deploy.targets.personal = { deploy.targets.personal = {
tf = { tf = {
@ -6,20 +6,14 @@
provider = "null"; provider = "null";
type = "resource"; type = "resource";
connection = { connection = {
port = 62954; port = head config.network.nodes.samhain.services.openssh.ports;
host = "192.168.1.135"; host = config.network.nodes.samhain.network.addresses.private.ipv4.address;
}; };
}; };
}; };
}; };
network.nodes.samhain = { network.nodes.samhain = {
imports = lib.hostImport { imports = kw.nodeImport "samhain";
hostName = "samhain";
inherit profiles root;
};
networking = {
hostName = "samhain";
};
}; };
}; };
} }

View file

@ -1,4 +1,4 @@
{ meta, profiles, config, root, lib, ... }: with lib; { { config, lib, kw, ... }: with lib; {
config = { config = {
deploy.targets.personal = { deploy.targets.personal = {
tf = { tf = {
@ -6,20 +6,14 @@
provider = "null"; provider = "null";
type = "resource"; type = "resource";
connection = { connection = {
port = 62954; port = head config.network.nodes.yule.services.openssh.ports;
host = meta.network.nodes.yule.network.addresses.private.ipv4.address; host = config.network.nodes.yule.network.addresses.private.ipv4.address;
}; };
}; };
}; };
}; };
network.nodes.yule = { network.nodes.yule = {
imports = lib.hostImport { imports = kw.nodeImport "yule";
hostName = "yule";
inherit profiles root;
};
networking = {
hostName = "yule";
};
}; };
}; };
} }

View file

@ -2,8 +2,8 @@
{ {
disabledModules = [ "programs/vim.nix" ]; disabledModules = [ "programs/vim.nix" ];
imports = with (import (sources.arcexprs + "/modules")).home-manager; [ base16 syncplay konawall i3gopher weechat shell ] imports = [
++ [ (import (sources.arcexprs + "/modules")).home-manager
(import (sources.katexprs + "/modules")).home (import (sources.katexprs + "/modules")).home
./vim.nix ./vim.nix
./fvwm.nix ./fvwm.nix

View file

@ -2,6 +2,7 @@
{ {
imports = [ imports = [
./imports.nix
./deploy.nix ./deploy.nix
./network.nix ./network.nix
]; ];

View file

@ -0,0 +1,41 @@
{ config, lib, profiles, root, ... }:
with lib;
{
options = {
lib = mkOption {
type = types.attrsOf (types.attrsOf types.unspecified);
};
network.importing = {
nixosImports = mkOption {
type = types.listOf types.str;
};
homeImports = mkOption {
type = types.listOf types.str;
};
users = mkOption {
type = types.listOf types.str;
};
};
};
config = {
network.importing = {
nixosImports = mkDefault (map (path: toString path) [
(root + "/depot/hosts/HN/nixos.nix")
(root + "/depot/trusted/hosts/HN/nixos.nix")
]);
homeImports = mkDefault (map (path: toString path) [
(root + "/depot/hosts/HN/home.nix")
(root + "/depot/trusted/hosts/HN/home.nix")
]);
users = mkDefault (singleton "kat");
};
lib.kw.nodeImport = hostName: lib.nodeImport {
inherit (config.network.importing) nixosImports homeImports users;
inherit profiles hostName;
};
_module.args = { inherit (config.lib) kw; };
};
}

View file

@ -2,8 +2,8 @@
{ {
imports = imports =
with (import (sources.arcexprs + "/modules")).nixos; [ base16 base16-shared modprobe ] [
++ [ (import (sources.arcexprs + "/modules")).nixos
(import (sources.katexprs + "/modules")).nixos (import (sources.katexprs + "/modules")).nixos
./deploy.nix ./deploy.nix
./dyndns.nix ./dyndns.nix

View file

@ -2,4 +2,6 @@
{ {
network.nftables.enable = lib.mkDefault true; network.nftables.enable = lib.mkDefault true;
network.enable = true;
network.dns.enable = true;
} }

View file

@ -5,7 +5,6 @@
./vim ./vim
./zsh.nix ./zsh.nix
./git.nix ./git.nix
./kitty.nix
./tmux.nix ./tmux.nix
./base16.nix ./base16.nix
./xdg.nix ./xdg.nix

View file

@ -1,6 +0,0 @@
{ config, pkgs, ... }:
{
# home.sessionVariables.TERMINFO_DIRS =
# "${pkgs.kitty.terminfo.outPath}/share/terminfo";
}

View file

@ -5,10 +5,10 @@
"homepage": null, "homepage": null,
"owner": "arcnmx", "owner": "arcnmx",
"repo": "nixexprs", "repo": "nixexprs",
"rev": "822807052f3aaee25216f457eb638a67df40a440", "rev": "36030e4a634792f9a9f3b029151148f3153839ab",
"sha256": "13ypw9z869j1vh4mjqjd6c3g69mxi7zhwy4v9ydrrvn2mxrdckw3", "sha256": "0hgfl2k03gs1rzippkmvqaw7knp87p9yplr9ivn7l25a2nb42g7s",
"type": "tarball", "type": "tarball",
"url": "https://github.com/arcnmx/nixexprs/archive/822807052f3aaee25216f457eb638a67df40a440.tar.gz", "url": "https://github.com/arcnmx/nixexprs/archive/36030e4a634792f9a9f3b029151148f3153839ab.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"ci": { "ci": {
@ -41,10 +41,10 @@
"homepage": "https://nix-community.github.io/home-manager/", "homepage": "https://nix-community.github.io/home-manager/",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "ad0fc085c7b954d5813a950cf0db7143e6b049e3", "rev": "72394f6d6b1cee26021c3e319fa249122ad33d82",
"sha256": "1m5fprdnbl38hfvj65m67nqpajjs3ngz92flx9zfzwpkj8nhvcvf", "sha256": "1hnkc81p50qq3zmk75bb132ks9w62mssy76xf2xamqlm6y0k0425",
"type": "tarball", "type": "tarball",
"url": "https://github.com/nix-community/home-manager/archive/ad0fc085c7b954d5813a950cf0db7143e6b049e3.tar.gz", "url": "https://github.com/nix-community/home-manager/archive/72394f6d6b1cee26021c3e319fa249122ad33d82.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"katexprs": { "katexprs": {
@ -53,10 +53,10 @@
"homepage": null, "homepage": null,
"owner": "kittywitch", "owner": "kittywitch",
"repo": "nixexprs", "repo": "nixexprs",
"rev": "87128f86cdcb18a558fe69a6f944b12c9bf9d1d2", "rev": "d651a2cabe9b9b6cee505aefdd6df1a2d2fdfef6",
"sha256": "1pjqshaspgmj8iq40s2krr30q5knmfwkvdrp1php0ck168nrvw50", "sha256": "11apd0jdzlwa0xf4kq5d2gizb83w70im5hgi7n1x0jbvyimxw9dp",
"type": "tarball", "type": "tarball",
"url": "https://github.com/kittywitch/nixexprs/archive/87128f86cdcb18a558fe69a6f944b12c9bf9d1d2.tar.gz", "url": "https://github.com/kittywitch/nixexprs/archive/d651a2cabe9b9b6cee505aefdd6df1a2d2fdfef6.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"niv": { "niv": {
@ -99,10 +99,10 @@
"homepage": "https://nur.nix-community.org/", "homepage": "https://nur.nix-community.org/",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "44fa56b415dcb37566e686c32b0877a0f8ab9829", "rev": "500f9f4002243ac3d7478348495d830abb6721e0",
"sha256": "1alf0yy0yarbzpq48176bad0zby4slq6ya6nfisx38hf14djhpr1", "sha256": "1plvb4byi2y4l6l4v501hb45s1kqhnz37raba476q4zkv82x6qi7",
"type": "tarball", "type": "tarball",
"url": "https://github.com/nix-community/NUR/archive/44fa56b415dcb37566e686c32b0877a0f8ab9829.tar.gz", "url": "https://github.com/nix-community/NUR/archive/500f9f4002243ac3d7478348495d830abb6721e0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"tf-nix": { "tf-nix": {
@ -111,10 +111,10 @@
"homepage": null, "homepage": null,
"owner": "arcnmx", "owner": "arcnmx",
"repo": "tf-nix", "repo": "tf-nix",
"rev": "bc910bd03053db59e5023eaea96e746a5391a4f9", "rev": "389de5b7a2843eea2208b056ed6a36d73260f2b0",
"sha256": "0x5hi75lsqqs9ppi1095g9y2jsm1r47y110wj1j9652cksykqhis", "sha256": "0p2z5w61g404sin2pb6vwq83dm1d1kkrfpwwc7q2jc7zgpwb3plv",
"type": "tarball", "type": "tarball",
"url": "https://github.com/arcnmx/tf-nix/archive/bc910bd03053db59e5023eaea96e746a5391a4f9.tar.gz", "url": "https://github.com/arcnmx/tf-nix/archive/389de5b7a2843eea2208b056ed6a36d73260f2b0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
} }
} }