feat(configurations)!: flatten down, introduce meta.nix
Flatten down directory structure: - From: `./hosts/${configuration-type}/${system}/{configuration,deploy}.nix` - To: `./hosts/${configuration-type}/{meta,configuration}.nix` Keep `system` and `deploy-rs` config in `meta.nix` Update `flake.lock`
This commit is contained in:
parent
29738555b1
commit
9b8f894a1a
43 changed files with 459 additions and 344 deletions
90
flake.lock
90
flake.lock
|
@ -14,11 +14,11 @@
|
|||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722339003,
|
||||
"narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=",
|
||||
"lastModified": 1723293904,
|
||||
"narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=",
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7",
|
||||
"rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -37,11 +37,11 @@
|
|||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722299223,
|
||||
"narHash": "sha256-+5HNJBXb9YXKSmi2TJsnftrgU/msF/4jBAMH9J1bc5c=",
|
||||
"lastModified": 1722597419,
|
||||
"narHash": "sha256-YbMzll0Dh2ln/TryDP+S3IGm8nRHkzcSQIubI4ZEOAw=",
|
||||
"owner": "oddlama",
|
||||
"repo": "agenix-rekey",
|
||||
"rev": "4107b53b152f4ddc504269ec17c4b7005869d762",
|
||||
"rev": "126b4a5133eb361cbf5bf90e44c71b6f830845ec",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -175,11 +175,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722476845,
|
||||
"narHash": "sha256-7gZ8uf3qOox8Vrwd+p9EhUHHLhhK8lis/5KcXGmIaow=",
|
||||
"lastModified": 1723426710,
|
||||
"narHash": "sha256-yrS9al6l3fYfFfvovnyBWnyELDQOdfKyai4K/jKgoBw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "7e1b215a0a96efb306ad6440bf706d2b307dc267",
|
||||
"rev": "0d510fe40b56ed74907a021d7e1ffd0042592914",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -367,11 +367,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719994518,
|
||||
"narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=",
|
||||
"lastModified": 1722555600,
|
||||
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7",
|
||||
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -576,11 +576,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1721042469,
|
||||
"narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=",
|
||||
"lastModified": 1723202784,
|
||||
"narHash": "sha256-qbhjc/NEGaDbyy0ucycubq4N3//gDFFH3DOmp1D3u1Q=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
|
||||
"rev": "c7012d0c18567c889b948781bc74a501e92275d1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -678,11 +678,11 @@
|
|||
},
|
||||
"hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1722332872,
|
||||
"narHash": "sha256-2xLM4sc5QBfi0U/AANJAW21Bj4ZX479MHPMPkB+eKBU=",
|
||||
"lastModified": 1723310128,
|
||||
"narHash": "sha256-IiH8jG6PpR4h9TxSGMYh+2/gQiJW9MwehFvheSb5rPc=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "14c333162ba53c02853add87a0000cbd7aa230c2",
|
||||
"rev": "c54cf53e022b0b3c1d3b8207aa0f9b194c24f0cf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -720,11 +720,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722462338,
|
||||
"narHash": "sha256-ss0G8t8RJVDewA3MyqgAlV951cWRK6EtVhVKEZ7J5LU=",
|
||||
"lastModified": 1723399884,
|
||||
"narHash": "sha256-97wn0ihhGqfMb8WcUgzzkM/TuAxce2Gd20A8oiruju4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "6e090576c4824b16e8759ebca3958c5b09659ee8",
|
||||
"rev": "086f619dd991a4d355c07837448244029fc2d9ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -756,11 +756,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722491724,
|
||||
"narHash": "sha256-pvZ0sqDNhcUzYXrCF9UYZBf+qd3ri/0fT0b4mFqVuBs=",
|
||||
"lastModified": 1723367191,
|
||||
"narHash": "sha256-noi5tre7BLtxImN38jEHeVOtOG1Xu37sJFwHKSAPHjo=",
|
||||
"owner": "Jovian-Experiments",
|
||||
"repo": "Jovian-NixOS",
|
||||
"rev": "ff83ee27a56651dcd6d4c9b3e3b7c08267dc52ae",
|
||||
"rev": "91178062f365b64eece94c5dff93e09b07e87d9d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -827,11 +827,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722471252,
|
||||
"narHash": "sha256-rgNPBiWN+y2jBiXIEgV/McBfkPeZax80eol0FBoupCk=",
|
||||
"lastModified": 1723528508,
|
||||
"narHash": "sha256-4++qlOlqMoZz3h/g48f+TY3r75h+EBToRNmgcVWKpsE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "neovim-nightly-overlay",
|
||||
"rev": "fe7178b41d84add25c63a695620629050fb35bbd",
|
||||
"rev": "f019c7b0e7f478e4aaf2b406785a8d6ec6d1957d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -843,11 +843,11 @@
|
|||
"neovim-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1722463651,
|
||||
"narHash": "sha256-3YorBqxT1RpL3Z2rLDCJhG+1HnBsgjrW8AOlTkFWlbA=",
|
||||
"lastModified": 1723504195,
|
||||
"narHash": "sha256-Tt+UtP3iSQATu2CUgFgtPkobASE7Rbf2AWZeLH8fthU=",
|
||||
"owner": "neovim",
|
||||
"repo": "neovim",
|
||||
"rev": "e820474cde09273608be5f57e1032aab21e3c97d",
|
||||
"rev": "9768e88f3891b5594eb2d556bd3bdf40c61d46e1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -882,11 +882,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722500642,
|
||||
"narHash": "sha256-Vls0TQRdplex1JslnBxEk3M26Q1vR+OSg+sk5rBG4DA=",
|
||||
"lastModified": 1722924007,
|
||||
"narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "b47af8628624856ad6853168298f1f96364d92d6",
|
||||
"rev": "91010a5613ffd7ee23ee9263213157a1c422b705",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1123,11 +1123,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1722421184,
|
||||
"narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=",
|
||||
"lastModified": 1723362943,
|
||||
"narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58",
|
||||
"rev": "a58bc8ad779655e790115244571758e8de055e3d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1225,11 +1225,11 @@
|
|||
},
|
||||
"nur": {
|
||||
"locked": {
|
||||
"lastModified": 1722577920,
|
||||
"narHash": "sha256-+Nilyq9pr3f13pNqE3UaJ/zxB69fQ8MmkA5xu6oYtIs=",
|
||||
"lastModified": 1723549487,
|
||||
"narHash": "sha256-65NYBcYUx0DjL7TGlesle5PdtJVfOCPnv5zvsgB/dRw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "NUR",
|
||||
"rev": "a3f8a8853ee2e17c2efd5a33a5c91c1d79bc9c49",
|
||||
"rev": "20b1fc4032363116a880dc64e3fa96f8a24d4e64",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1701,11 +1701,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722558337,
|
||||
"narHash": "sha256-001MFcaVzqfl/d+dhAz4FTWHlHCYU/7nZ9OVWiYLkeI=",
|
||||
"lastModified": 1723551051,
|
||||
"narHash": "sha256-+H7sSt93MLs82ZVdhuHlUPfUL+anMvR3+UrVyZTIxjo=",
|
||||
"owner": "mitchellh",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "93eec9c6ff998133fdeed5eb96c4c59fc2b66b7c",
|
||||
"rev": "2a8a3228bca531f3c4482268f7262dacf372baf6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1727,11 +1727,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722209386,
|
||||
"narHash": "sha256-GAzXTJUJJIXrAlHkInSDwlnVQPL5BV1Enbj3R4ipGFk=",
|
||||
"lastModified": 1723396350,
|
||||
"narHash": "sha256-f5RTadUCYeGPDI6Y7xDYa6sJsdKFCdtD4WipGxuof3A=",
|
||||
"owner": "zigtools",
|
||||
"repo": "zls",
|
||||
"rev": "eba1489b6ffa6db7f0eaefce6e06d53cd9066f7b",
|
||||
"rev": "3ec8ad16337e5fc391fbdfb394f68f155b2a7a69",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
11
flake.nix
11
flake.nix
|
@ -17,7 +17,6 @@
|
|||
./modules/flake/modules
|
||||
./modules/flake/configurations
|
||||
./modules/flake/agenix
|
||||
./modules/flake/deploy
|
||||
./modules/flake/topology
|
||||
./modules/flake/packages
|
||||
./modules/flake/overlays
|
||||
|
@ -35,19 +34,19 @@
|
|||
flake = {
|
||||
inherit (inputs) self;
|
||||
|
||||
# Automatic modules, see `./modules/flake/modules.nix`
|
||||
# Automatic modules, see `./modules/flake/modules/default.nix`
|
||||
autoModules.enableAll = true;
|
||||
|
||||
# Automatic configurations, see `./modules/flake/configurations.nix`
|
||||
# Automatic configurations, see `./modules/flake/configurations/default.nix`
|
||||
autoConfigurations.enableAll = true;
|
||||
|
||||
# Automatic packages, see `./modules/flake/packages/default.nix`
|
||||
# Automatic packages, see `./modules/flake/packages/default/default.nix`
|
||||
autoPackages.enable = true;
|
||||
|
||||
# Automatic overlays, see `./modules/flake/overlays/default.nix`
|
||||
# Automatic overlays, see `./modules/flake/overlays/default/default.nix`
|
||||
autoOverlays.enable = true;
|
||||
|
||||
# Automatic devShells, see `./modules/flake/shells/default.nix`
|
||||
# Automatic devShells, see `./modules/flake/shells/default/default.nix`
|
||||
autoDevShells.enable = true;
|
||||
|
||||
# Templates
|
||||
|
|
3
hosts/home-manager/__template__/meta.nix
Normal file
3
hosts/home-manager/__template__/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "x86_64-linux";
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
# Zig
|
||||
zigpkgs.master
|
||||
inputs.zls-overlay.packages.x86_64-darwin.default
|
||||
# inputs.zls-overlay.packages.x86_64-darwin.default
|
||||
];
|
||||
|
||||
programs.git = {
|
3
hosts/nix-darwin/apavel-a01/meta.nix
Normal file
3
hosts/nix-darwin/apavel-a01/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "x86_64-darwin";
|
||||
}
|
|
@ -66,7 +66,7 @@
|
|||
nurl
|
||||
|
||||
# Mail
|
||||
# himalaya
|
||||
himalaya
|
||||
|
||||
# Java
|
||||
graalvm-ce
|
||||
|
@ -87,7 +87,7 @@
|
|||
|
||||
# Zig
|
||||
zigpkgs.master
|
||||
inputs.zls-overlay.packages.${pkgs.system}.default
|
||||
# inputs.zls-overlay.packages.${pkgs.system}.default
|
||||
|
||||
# Android
|
||||
android-tools
|
15
hosts/nix-darwin/limonka/meta.nix
Normal file
15
hosts/nix-darwin/limonka/meta.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
system = "aarch64-darwin";
|
||||
deploy = {
|
||||
hostname = "localhost";
|
||||
sshUser = "pavelatanasov";
|
||||
user = "pavelatanasov";
|
||||
sudo = "sudo -u";
|
||||
sshOpts = [ ];
|
||||
fastConnection = false;
|
||||
autoRollback = true;
|
||||
magicRollback = true;
|
||||
tempPath = "/Users/pavelatanasov/.deploy-rs";
|
||||
remoteBuild = true;
|
||||
};
|
||||
}
|
3
hosts/nix-darwin/limontozu/meta.nix
Normal file
3
hosts/nix-darwin/limontozu/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "x86_64-darwin";
|
||||
}
|
3
hosts/nix-on-droid/cheetah/meta.nix
Normal file
3
hosts/nix-on-droid/cheetah/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "aarch64-linux";
|
||||
}
|
3
hosts/nixos/__template__/meta.nix
Normal file
3
hosts/nixos/__template__/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "x86_64-linux";
|
||||
}
|
3
hosts/nixos/homix/meta.nix
Normal file
3
hosts/nixos/homix/meta.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
system = "x86_64-linux";
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
# services.kanidm = { };
|
||||
|
||||
age.rekey = {
|
||||
# TODO: store in `meta`
|
||||
hostPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPopSTZ81UyKp9JSljCLp+Syk51zacjh9fLteqxQ6/aB";
|
||||
# masterIdentities = [ "${inputs.self}/secrets/privkey.age" ];
|
||||
# storageMode = "local";
|
||||
|
@ -74,7 +75,10 @@
|
|||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
neovim
|
||||
# FIXME: cannot deploy neovim-nightly
|
||||
# V neovim source
|
||||
# > error: cannot add path '/nix/store/rhjznh5jdzdkzbnn0fhhvcf9rys0s59d-source' because it lacks a signature by a trusted key
|
||||
# neovim
|
||||
];
|
||||
|
||||
# NOTE: made with `mkpasswd -m sha-512`
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
home.packages = with pkgs; [
|
||||
## Core
|
||||
neovim
|
||||
# neovim
|
||||
git
|
||||
gnupg
|
||||
pciutils # lspci
|
48
hosts/nixos/jeeves/meta.nix
Normal file
48
hosts/nixos/jeeves/meta.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
# The `system` of the host
|
||||
system = "x86_64-linux";
|
||||
|
||||
# `deploy-rs` configuration
|
||||
deploy = {
|
||||
# This is the hostname by which you'll refer to this machine using reploy-rs
|
||||
hostname = "jeeves.reo101.xyz";
|
||||
|
||||
# This is the user that deploy-rs will use when connecting.
|
||||
# This will default to your own username if not specified anywhere
|
||||
sshUser = "jeeves";
|
||||
|
||||
# This is the user that the profile will be deployed to (will use sudo if not the same as above).
|
||||
# If `sshUser` is specified, this will be the default (though it will _not_ default to your own username)
|
||||
user = "root";
|
||||
|
||||
# Which sudo command to use. Must accept at least two arguments:
|
||||
# the user name to execute commands as and the rest is the command to execute
|
||||
# This will default to "sudo -u" if not specified anywhere.
|
||||
sudo = "sudo -u";
|
||||
|
||||
# This is an optional list of arguments that will be passed to SSH.
|
||||
sshOpts = [ "-p" "727" ];
|
||||
|
||||
# Fast connection to the node. If this is true, copy the whole closure instead of letting the node substitute.
|
||||
# This defaults to `false`
|
||||
fastConnection = false;
|
||||
|
||||
# If the previous profile should be re-activated if activation fails.
|
||||
# This defaults to `true`
|
||||
autoRollback = true;
|
||||
|
||||
# See the earlier section about Magic Rollback for more information.
|
||||
# This defaults to `true`
|
||||
magicRollback = true;
|
||||
|
||||
# The path which deploy-rs will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations
|
||||
# If not specified, this will default to `/tmp`
|
||||
# (if `magicRollback` is in use, this _must_ be writable by `user`)
|
||||
tempPath = "/tmp";
|
||||
|
||||
# Build the derivation on the target system
|
||||
# Will also fetch all external dependencies from the target system's substituters.
|
||||
# This default to `false`
|
||||
remoteBuild = true;
|
||||
};
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
# This is the hostname by which you'll refer to this machine using reploy-rs
|
||||
hostname = "jeeves.reo101.xyz";
|
||||
|
||||
# This is the user that deploy-rs will use when connecting.
|
||||
# This will default to your own username if not specified anywhere
|
||||
sshUser = "jeeves";
|
||||
|
||||
# This is the user that the profile will be deployed to (will use sudo if not the same as above).
|
||||
# If `sshUser` is specified, this will be the default (though it will _not_ default to your own username)
|
||||
user = "root";
|
||||
|
||||
# Which sudo command to use. Must accept at least two arguments:
|
||||
# the user name to execute commands as and the rest is the command to execute
|
||||
# This will default to "sudo -u" if not specified anywhere.
|
||||
sudo = "sudo -u";
|
||||
|
||||
# This is an optional list of arguments that will be passed to SSH.
|
||||
sshOpts = [ "-p" "727" ];
|
||||
|
||||
# Fast connection to the node. If this is true, copy the whole closure instead of letting the node substitute.
|
||||
# This defaults to `false`
|
||||
fastConnection = false;
|
||||
|
||||
# If the previous profile should be re-activated if activation fails.
|
||||
# This defaults to `true`
|
||||
autoRollback = true;
|
||||
|
||||
# See the earlier section about Magic Rollback for more information.
|
||||
# This defaults to `true`
|
||||
magicRollback = true;
|
||||
|
||||
# The path which deploy-rs will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations
|
||||
# If not specified, this will default to `/tmp`
|
||||
# (if `magicRollback` is in use, this _must_ be writable by `user`)
|
||||
tempPath = "/tmp";
|
||||
|
||||
# Build the derivation on the target system
|
||||
# Will also fetch all external dependencies from the target system's substituters.
|
||||
# This default to `false`
|
||||
remoteBuild = true;
|
||||
}
|
|
@ -6,11 +6,12 @@ let
|
|||
hasFiles
|
||||
hasDirectories
|
||||
recurseDir
|
||||
configuration-type-to-outputs-modules;
|
||||
kebabToCamel
|
||||
configuration-type-to-outputs-modules
|
||||
configuration-type-to-outputs-configurations;
|
||||
in
|
||||
let
|
||||
# Configuration helpers
|
||||
configurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"];
|
||||
|
||||
# `pkgs` with flake's overlays
|
||||
# NOTE: done here to avoid infinite recursion
|
||||
|
@ -18,7 +19,15 @@ let
|
|||
(withSystem system ({ pkgs, ... }: pkgs)).extend
|
||||
(final: prev: inputs.self.packages.${system});
|
||||
|
||||
homeManagerModule = { root, system, hostname, users ? null }: {
|
||||
genUsers = configurationFiles:
|
||||
lib.pipe configurationFiles [
|
||||
(cf: cf."home" or { })
|
||||
builtins.attrNames
|
||||
(builtins.map
|
||||
(lib.strings.removeSuffix ".nix"))
|
||||
];
|
||||
|
||||
homeManagerModule = { root, meta, users ? null }: {
|
||||
home-manager = {
|
||||
# Use same `pkgs` instance as system (i.e. carry over overlays)
|
||||
useGlobalPkgs = true;
|
||||
|
@ -26,11 +35,10 @@ let
|
|||
useUserPackages = true;
|
||||
# Default import all of our exported `home-manager` modules
|
||||
sharedModules = builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"};
|
||||
# Pass in `inputs`, `outputs` and maybe `meta`
|
||||
# Pass in `inputs`, `hostname` and `meta`
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
# TODO: meta?
|
||||
inherit hostname;
|
||||
inherit meta;
|
||||
};
|
||||
} // (if users == null then {
|
||||
# nixOnDroid
|
||||
|
@ -44,9 +52,9 @@ let
|
|||
});
|
||||
};
|
||||
|
||||
mkNixosHost = args @ { root, system, hostname, users }: inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
pkgs = pkgs' system;
|
||||
mkNixosHost = args @ { root, meta, users }: inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit (meta) system;
|
||||
pkgs = pkgs' meta.system;
|
||||
|
||||
modules = [
|
||||
# Main configuration
|
||||
|
@ -61,19 +69,21 @@ let
|
|||
inputs.nix-topology.nixosModules.default
|
||||
# Sane default `networking.hostName`
|
||||
{
|
||||
networking.hostName = lib.mkDefault hostname;
|
||||
networking.hostName = lib.mkDefault meta.hostname;
|
||||
}
|
||||
# TODO: lib.optionals
|
||||
] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nixos"});
|
||||
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
inherit meta;
|
||||
};
|
||||
};
|
||||
|
||||
mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
mkNixOnDroidHost = args @ { root, meta }: inputs.nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
# NOTE: inferred by `pkgs.system`
|
||||
# inherit system;
|
||||
pkgs = pkgs' system;
|
||||
pkgs = pkgs' meta.system;
|
||||
|
||||
modules = [
|
||||
# Main configuration
|
||||
|
@ -84,14 +94,15 @@ let
|
|||
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
inherit meta;
|
||||
};
|
||||
|
||||
home-manager-path = inputs.home-manager.outPath;
|
||||
};
|
||||
|
||||
mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem {
|
||||
inherit system;
|
||||
pkgs = pkgs' system;
|
||||
mkNixDarwinHost = args @ { root, meta, users }: inputs.nix-darwin.lib.darwinSystem {
|
||||
inherit (meta) system;
|
||||
pkgs = pkgs' meta.system;
|
||||
|
||||
modules = [
|
||||
# Main configuration
|
||||
|
@ -107,12 +118,13 @@ let
|
|||
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
inherit meta;
|
||||
};
|
||||
};
|
||||
|
||||
mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit system;
|
||||
pkgs = pkgs' system;
|
||||
mkHomeManagerHost = args @ { root, meta }: inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit (meta) system;
|
||||
pkgs = pkgs' meta.system;
|
||||
|
||||
modules = [
|
||||
"${root}/home.nix"
|
||||
|
@ -120,30 +132,9 @@ let
|
|||
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
inherit hostname;
|
||||
inherit meta;
|
||||
};
|
||||
};
|
||||
|
||||
createConfigurations =
|
||||
pred: mkHost: hosts:
|
||||
lib.foldAttrs
|
||||
lib.const
|
||||
[ ]
|
||||
(builtins.attrValues
|
||||
(builtins.mapAttrs
|
||||
(system: hosts:
|
||||
lib.concatMapAttrs
|
||||
(host: configurationFiles:
|
||||
lib.optionalAttrs
|
||||
(and [
|
||||
(host != "__template__")
|
||||
(pred { inherit system host configurationFiles; })
|
||||
])
|
||||
{
|
||||
${host} = mkHost { inherit system host configurationFiles; };
|
||||
})
|
||||
hosts)
|
||||
hosts));
|
||||
in
|
||||
{
|
||||
options = let
|
||||
|
@ -153,9 +144,18 @@ in
|
|||
description = ''
|
||||
Automagically generate configurations from walking directories with Nix files
|
||||
'';
|
||||
type = types.submodule (submodule: {
|
||||
internal = true;
|
||||
type = types.submodule (autoConfigurationsSubmodule: let
|
||||
inherit (autoConfigurationsSubmodule.config)
|
||||
configurationTypes
|
||||
enableAll
|
||||
baseDir
|
||||
;
|
||||
in {
|
||||
options = {
|
||||
enableAll = lib.mkEnableOption "Automatic ${builtins.toString configurationTypes} configurations extraction";
|
||||
enableAll = lib.mkEnableOption ''
|
||||
Automatic ${builtins.toString (lib.attrValues configurationTypes)} configurations extraction
|
||||
'';
|
||||
baseDir = lib.mkOption {
|
||||
description = ''
|
||||
Base directory of the contained configurations, used as a base for the rest of the options
|
||||
|
@ -164,135 +164,291 @@ in
|
|||
default = "${self}/hosts";
|
||||
defaultText = ''''${self}/hosts'';
|
||||
};
|
||||
} // (
|
||||
lib.pipe
|
||||
configurationTypes
|
||||
[
|
||||
(builtins.map
|
||||
# NOTE: create small submodule for every `configurationType`
|
||||
(configurationType:
|
||||
lib.nameValuePair
|
||||
"${configurationType}"
|
||||
(lib.mkOption {
|
||||
type = types.submodule {
|
||||
options = {
|
||||
# NOTE: each can be enabled (default global `enableAll`)
|
||||
enable = lib.mkEnableOption "Automatic ${configurationType} configurations extraction" // {
|
||||
default = submodule.config.enableAll;
|
||||
};
|
||||
# NOTE: each can be read from a different directory
|
||||
# (default global `baseDir` + `camelToKebab`-ed `configurationType`)
|
||||
dir = lib.mkOption {
|
||||
type = types.path;
|
||||
default = "${submodule.config.baseDir}/${configurationType}";
|
||||
};
|
||||
# TODO: split hosts and configurations?
|
||||
resultHosts = lib.mkOption {
|
||||
description = ''
|
||||
The resulting automatic packages
|
||||
'';
|
||||
# TODO: specify
|
||||
type = types.unspecified;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default =
|
||||
lib.optionalAttrs
|
||||
config.flake.autoConfigurations.${configurationType}.enable
|
||||
(recurseDir config.flake.autoConfigurations.${configurationType}.dir);
|
||||
configurationTypes = lib.mkOption {
|
||||
type = types.attrsOf (types.submodule (configurationTypeSubmodule@{ name, ... }: let
|
||||
inherit (configurationTypeSubmodule.config)
|
||||
# enable
|
||||
dir
|
||||
predicate
|
||||
mkHost
|
||||
mkDeployNode
|
||||
;
|
||||
in {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "Automatic ${name} configurations extraction" // {
|
||||
default = enableAll;
|
||||
};
|
||||
# NOTE: each can be read from a different directory
|
||||
dir = lib.mkOption {
|
||||
type = types.path;
|
||||
default = "${baseDir}/${name}";
|
||||
};
|
||||
hostsName = lib.mkOption {
|
||||
description = ''
|
||||
Name of the `hosts` output
|
||||
'';
|
||||
type = types.str;
|
||||
default = "${kebabToCamel name}Hosts";
|
||||
};
|
||||
configurationsName = lib.mkOption {
|
||||
description = ''
|
||||
Name of the `configurations` output
|
||||
'';
|
||||
type = types.str;
|
||||
default = "${kebabToCamel name}Configurations";
|
||||
};
|
||||
predicate = lib.mkOption {
|
||||
description = ''
|
||||
Function for filtering configurations
|
||||
'';
|
||||
# FIXME: `merge` of `functionTo` type causes a stray `passthru` to attempt getting evaluated
|
||||
# type = types.functionTo types.anything;
|
||||
type = types.unspecified;
|
||||
example = /* nix */ ''
|
||||
{ root, host, configurationFiles, ... }:
|
||||
# Utils from `./modules/flake/lib/default.nix`
|
||||
and [
|
||||
(! (host == "__template__"))
|
||||
(hasFiles
|
||||
[ "configuration.nix" ]
|
||||
configurationFiles)
|
||||
(hasDirectories
|
||||
[ "home" ]
|
||||
configurationFiles)
|
||||
]
|
||||
'';
|
||||
};
|
||||
mkHost = lib.mkOption {
|
||||
description = ''
|
||||
Function for generating a configuration
|
||||
'';
|
||||
# type = types.functionTo types.anything;
|
||||
type = types.unspecified;
|
||||
example = /* nix */ ''
|
||||
args @ { root, meta, users }: inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit (meta) system;
|
||||
|
||||
modules = [
|
||||
# Main configuration
|
||||
"''${root}/configuration.nix"
|
||||
# Home Manager
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
(homeManagerModule args)
|
||||
] ++ (builtins.attrValues config.flake.''${configuration-type-to-outputs-modules "nixos"});
|
||||
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
inherit meta;
|
||||
};
|
||||
};
|
||||
'';
|
||||
};
|
||||
mkDeployNode = lib.mkOption {
|
||||
description = ''
|
||||
Function for generating a `deploy-rs` node (null to skip)
|
||||
'';
|
||||
type = types.nullOr (types.functionTo types.anything);
|
||||
default = null;
|
||||
# TODO: update
|
||||
example = /* nix */ ''
|
||||
args @ { root, host, meta, configuration }:
|
||||
inputs.deploy-rs.''${meta.system}.activate.nixos configuration;
|
||||
'';
|
||||
};
|
||||
resultConfigurations = lib.mkOption {
|
||||
description = ''
|
||||
The resulting automatic configurations
|
||||
'';
|
||||
# TODO: specify
|
||||
type = types.unspecified;
|
||||
readOnly = true;
|
||||
default =
|
||||
lib.pipe dir [
|
||||
recurseDir
|
||||
(lib.concatMapAttrs
|
||||
(host: configurationFiles:
|
||||
let
|
||||
root = "${dir}/${host}";
|
||||
meta-path = "${root}/meta.nix";
|
||||
meta = import meta-path;
|
||||
deploy-config = meta.deploy or null;
|
||||
has-mkDeployNode = mkDeployNode != null;
|
||||
has-deploy-config = builtins.pathExists meta-path && deploy-config != null;
|
||||
configuration-args = { inherit root host configurationFiles; };
|
||||
valid = predicate configuration-args;
|
||||
configuration = mkHost configuration-args;
|
||||
deploy-args = { inherit root host meta configuration; };
|
||||
deploy = mkDeployNode deploy-args;
|
||||
in
|
||||
lib.optionalAttrs valid {
|
||||
${host} = {
|
||||
inherit configuration;
|
||||
} // lib.optionalAttrs (has-mkDeployNode && has-deploy-config) {
|
||||
inherit deploy;
|
||||
};
|
||||
}))
|
||||
];
|
||||
};
|
||||
};
|
||||
config = {};
|
||||
}));
|
||||
# TODO: put in a more visible place
|
||||
default = {
|
||||
nixos = {
|
||||
predicate = ({ root, host, configurationFiles, ... }:
|
||||
and [
|
||||
(! (host == "__template__"))
|
||||
(hasFiles
|
||||
[ "configuration.nix" "meta.nix" ]
|
||||
configurationFiles)
|
||||
]);
|
||||
mkHost = ({ root, host, configurationFiles, ... }: let
|
||||
meta = import "${root}/meta.nix" // {
|
||||
hostname = host;
|
||||
};
|
||||
default = {};
|
||||
})))
|
||||
builtins.listToAttrs
|
||||
]);
|
||||
in
|
||||
mkNixosHost {
|
||||
inherit root;
|
||||
inherit meta;
|
||||
users = genUsers configurationFiles;
|
||||
});
|
||||
mkDeployNode = ({ root, host, meta, configuration }:
|
||||
{
|
||||
inherit (meta.deploy) hostname;
|
||||
profiles.system = meta.deploy // {
|
||||
path = inputs.deploy-rs.lib.${meta.system}.activate."nixos" configuration;
|
||||
};
|
||||
});
|
||||
};
|
||||
nix-on-droid = {
|
||||
predicate = ({ root, host, configurationFiles, ... }:
|
||||
and [
|
||||
(! (host == "__template__"))
|
||||
(hasFiles
|
||||
[ "configuration.nix" "home.nix" "meta.nix" ]
|
||||
configurationFiles)
|
||||
]);
|
||||
mkHost = ({ root, host, configurationFiles, ... }: let
|
||||
meta = import "${root}/meta.nix" // {
|
||||
hostname = host;
|
||||
};
|
||||
in
|
||||
mkNixOnDroidHost {
|
||||
inherit root;
|
||||
inherit meta;
|
||||
});
|
||||
};
|
||||
nix-darwin = {
|
||||
hostsName = "darwinHosts";
|
||||
configurationsName = "darwinConfigurations";
|
||||
predicate = ({ root, host, configurationFiles, ... }:
|
||||
and [
|
||||
(! (host == "__template__"))
|
||||
(hasFiles
|
||||
[ "configuration.nix" "meta.nix" ]
|
||||
configurationFiles)
|
||||
(hasDirectories
|
||||
[ "home" ]
|
||||
configurationFiles)
|
||||
]);
|
||||
mkHost = ({ root, host, configurationFiles, ... }: let
|
||||
meta = import "${root}/meta.nix" // {
|
||||
hostname = host;
|
||||
};
|
||||
in
|
||||
mkNixDarwinHost {
|
||||
inherit root;
|
||||
inherit meta;
|
||||
users = genUsers configurationFiles;
|
||||
});
|
||||
mkDeployNode = ({ root, host, meta, configuration }:
|
||||
{
|
||||
inherit (meta.deploy) hostname;
|
||||
profiles.system = meta.deploy // {
|
||||
path = inputs.deploy-rs.lib.${meta.system}.activate."darwin" configuration;
|
||||
};
|
||||
});
|
||||
};
|
||||
home-manager = {
|
||||
hostsName = "homeHosts";
|
||||
configurationsName = "homeConfigurations";
|
||||
predicate = ({ root, host, configurationFiles, ... }:
|
||||
and [
|
||||
(! (host == "__template__"))
|
||||
(hasFiles
|
||||
[ "home.nix" "meta.nix" ]
|
||||
configurationFiles)
|
||||
]);
|
||||
mkHost = ({ root, host, configurationFiles, ... }: let
|
||||
meta = import "${root}/meta.nix" // {
|
||||
hostname = host;
|
||||
};
|
||||
in
|
||||
mkHomeManagerHost {
|
||||
inherit root;
|
||||
inherit meta;
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
resultConfigurations = lib.mkOption {
|
||||
readOnly = true;
|
||||
default = lib.pipe configurationTypes [
|
||||
(lib.mapAttrs'
|
||||
(configurationType: configurationTypeConfig:
|
||||
lib.nameValuePair
|
||||
configurationTypeConfig.configurationsName
|
||||
(lib.mapAttrs
|
||||
(host: { configuration, ... }:
|
||||
configuration)
|
||||
configurationTypeConfig.resultConfigurations)))
|
||||
];
|
||||
};
|
||||
resultDeployNodes = lib.mkOption {
|
||||
readOnly = true;
|
||||
default = lib.pipe configurationTypes [
|
||||
(lib.concatMapAttrs
|
||||
(configurationType: configurationTypeConfig:
|
||||
(lib.concatMapAttrs
|
||||
(host: { deploy ? null, ... }:
|
||||
lib.optionalAttrs
|
||||
(deploy != null)
|
||||
{
|
||||
${host} = deploy;
|
||||
})
|
||||
configurationTypeConfig.resultConfigurations)))
|
||||
];
|
||||
};
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
flake = {
|
||||
# Configurations
|
||||
nixosConfigurations =
|
||||
createConfigurations
|
||||
({ system, host, configurationFiles, ... }:
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" ]
|
||||
configurationFiles)
|
||||
# (hasDirectories
|
||||
# [ "home" ]
|
||||
# config)
|
||||
])
|
||||
({ system, host, configurationFiles, ... }:
|
||||
mkNixosHost {
|
||||
root = "${config.flake.autoConfigurations.nixos.dir}/${system}/${host}";
|
||||
inherit system;
|
||||
hostname = host;
|
||||
users = (builtins.map
|
||||
(lib.strings.removeSuffix ".nix")
|
||||
(builtins.attrNames (configurationFiles."home" or { })));
|
||||
})
|
||||
config.flake.autoConfigurations.nixos.resultHosts;
|
||||
|
||||
nixOnDroidConfigurations =
|
||||
createConfigurations
|
||||
({ system, host, configurationFiles, ... }:
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" "home.nix" ]
|
||||
configurationFiles)
|
||||
])
|
||||
({ system, host, configurationFiles, ... }:
|
||||
mkNixOnDroidHost {
|
||||
root = "${config.flake.autoConfigurations.nix-on-droid.dir}/${system}/${host}";
|
||||
inherit system;
|
||||
hostname = host;
|
||||
})
|
||||
config.flake.autoConfigurations.nix-on-droid.resultHosts;
|
||||
|
||||
darwinConfigurations =
|
||||
createConfigurations
|
||||
({ system, host, configurationFiles, ... }:
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "configuration.nix" ]
|
||||
configurationFiles)
|
||||
(hasDirectories
|
||||
[ "home" ]
|
||||
configurationFiles)
|
||||
])
|
||||
({ system, host, configurationFiles, ... }:
|
||||
mkNixDarwinHost {
|
||||
root = "${config.flake.autoConfigurations.nix-darwin.dir}/${system}/${host}";
|
||||
inherit system;
|
||||
hostname = host;
|
||||
users = (builtins.map
|
||||
(lib.strings.removeSuffix ".nix")
|
||||
(builtins.attrNames (configurationFiles."home" or { })));
|
||||
})
|
||||
config.flake.autoConfigurations.nix-darwin.resultHosts;
|
||||
|
||||
homeConfigurations =
|
||||
createConfigurations
|
||||
({ system, host, configurationFiles, ... }:
|
||||
and
|
||||
[
|
||||
(hasFiles
|
||||
[ "home.nix" ]
|
||||
configurationFiles)
|
||||
])
|
||||
({ system, host, configurationFiles, ... }:
|
||||
mkHomeManagerHost {
|
||||
root = "${config.flake.autoConfigurations.home-manager.dir}/${system}/${host}";
|
||||
inherit system;
|
||||
hostname = host;
|
||||
})
|
||||
config.flake.autoConfigurations.home-manager.resultHosts;
|
||||
};
|
||||
# BUG: cannot iterate on `config.flake.autoConfigurations.resultConfigurations`
|
||||
# because of infinite recursion
|
||||
flake = let
|
||||
ogConfigurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"];
|
||||
configurations = lib.pipe ogConfigurationTypes [
|
||||
(lib.map
|
||||
configuration-type-to-outputs-configurations)
|
||||
(lib.flip lib.genAttrs
|
||||
(configurationType:
|
||||
config.flake.autoConfigurations.resultConfigurations.${configurationType}))
|
||||
];
|
||||
deployNodes = {
|
||||
deploy.nodes = config.flake.autoConfigurations.resultDeployNodes;
|
||||
};
|
||||
deployChecks = {
|
||||
checks =
|
||||
lib.mapAttrs
|
||||
(system: deployLib:
|
||||
deployLib.deployChecks
|
||||
self.deploy)
|
||||
inputs.deploy-rs.lib;
|
||||
};
|
||||
# TODO: lib.something for merging (asserting for no overwrites)
|
||||
in configurations // deployNodes // deployChecks;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
{ lib, config, self, inputs, ... }:
|
||||
|
||||
let
|
||||
inherit (config.lib)
|
||||
accumulateHosts
|
||||
configuration-type-to-deploy-type;
|
||||
in
|
||||
{
|
||||
flake = {
|
||||
deploy.nodes =
|
||||
accumulateHosts
|
||||
# TODO: nix-on-droid
|
||||
["nixos" "nix-darwin"]
|
||||
({ host, system, configuration-type, configuration }:
|
||||
let
|
||||
deploy-config-path =
|
||||
"${config.flake.autoConfigurations.${configuration-type}.dir}/${system}/${host}/deploy.nix";
|
||||
deploy-config =
|
||||
import deploy-config-path;
|
||||
in
|
||||
lib.optionalAttrs
|
||||
(builtins.pathExists deploy-config-path)
|
||||
{
|
||||
${host} = {
|
||||
inherit (deploy-config)
|
||||
hostname;
|
||||
profiles.system = deploy-config // {
|
||||
path =
|
||||
let
|
||||
deploy-type = configuration-type-to-deploy-type configuration-type;
|
||||
in
|
||||
inputs.deploy-rs.lib.${system}.activate.${deploy-type} configuration;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
checks =
|
||||
lib.mapAttrs
|
||||
(system: deployLib:
|
||||
deployLib.deployChecks
|
||||
self.deploy)
|
||||
inputs.deploy-rs.lib;
|
||||
};
|
||||
}
|
|
@ -121,43 +121,5 @@
|
|||
(configuration-type:
|
||||
builtins.throw
|
||||
"Invaild configuration-type \"${configuration-type}\" for deploy-rs deployment");
|
||||
|
||||
accumulateHosts = configuration-types: host-system-configuration-type-configuration-fn:
|
||||
lib.flip lib.concatMapAttrs
|
||||
(lib.genAttrs
|
||||
configuration-types
|
||||
(configuration-type:
|
||||
config.flake.autoConfigurations.${configuration-type}.resultHosts))
|
||||
(configuration-type: hosts:
|
||||
lib.pipe
|
||||
hosts
|
||||
[
|
||||
# Filter out nondirectories
|
||||
(lib.filterAttrs
|
||||
(system: configurations:
|
||||
builtins.isAttrs configurations))
|
||||
# Convert non-template configs into `system-and-config` pairs
|
||||
(lib.concatMapAttrs
|
||||
(system: configurations:
|
||||
(lib.concatMapAttrs
|
||||
(host: configuration:
|
||||
lib.optionalAttrs
|
||||
(host != "__template__")
|
||||
{
|
||||
${host} = {
|
||||
inherit system;
|
||||
configuration =
|
||||
let
|
||||
configurations = configuration-type-to-outputs-configurations configuration-type;
|
||||
in
|
||||
self.${configurations}.${host};
|
||||
};
|
||||
})
|
||||
configurations)))
|
||||
# Convert each `system-and-config` pair into a *whatever*
|
||||
(lib.concatMapAttrs
|
||||
(host: { system, configuration }:
|
||||
host-system-configuration-type-configuration-fn { inherit host system configuration-type configuration; }))
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue