Flatten apps (nixinate-name instead nixinate.name) #50

Merged
tristan merged 1 commit from fix-flake-app-hierarchy into master 2023-12-11 20:03:59 +00:00
3 changed files with 28 additions and 29 deletions

View file

@ -8,6 +8,7 @@
> Changes so far:
> - Merged a helpful PR for ssh config hostnames https://git.vlt81.de/tristan/nixinate/pulls/49
> - Fixed nix run on non-posix compliant shells like fish by explicitly adding a bash shim to the script
> - Solved https://git.vlt81.de/tristan/nixinate/issues/12 by renaming apps from `nixinate.{$machine_name}` to `nixinate-${machine_name]}`
>
> PR's welcome :)
@ -75,12 +76,12 @@ git+file:///etc/nixos
└───myMachine: NixOS configuration
```
To finally execute the deployment script, use `nix run .#apps.nixinate.myMachine`
To finally execute the deployment script, use `nix run .#apps.nixinate-myMachine`
#### Example Run
```
[root@myMachine:/etc/nixos]# nix run .#apps.nixinate.myMachine
[root@myMachine:/etc/nixos]# nix run .#apps.nixinate-myMachine
🚀 Deploying nixosConfigurations.myMachine from /nix/store/279p8aaclmng8kc3mdmrmi6q3n76r1i7-source
👤 SSH User: matthew
🌐 SSH Host: itchy.scratchy.com

View file

@ -118,33 +118,31 @@
in
final.writeScript "deploy-${machine}.sh" script;
in
{
nixinate = (
(
nixpkgs.lib.genAttrs
validMachines
(map (a: "nixinate-" + a) validMachines)
(
x: {
type = "app";
program = toString (mkDeployScript {
machine = x;
machine = nixpkgs.lib.removePrefix "nixinate-" x;
dryRun = false;
});
}
)
// nixpkgs.lib.genAttrs
(map (a: a + "-dry-run") validMachines)
(map (a: "nixinate-" + a + "-dry-run") validMachines)
(
x: {
type = "app";
program = toString (mkDeployScript {
machine = nixpkgs.lib.removeSuffix "-dry-run" x;
machine = nixpkgs.lib.removePrefix "nixinate-" nixpkgs.lib.removeSuffix "-dry-run" x;
dryRun = true;
});
}
)
);
};
};
nixinate = forAllSystems (system: pkgs: nixpkgsFor.${system}.generateApps);
checks = forAllSystems (
system: pkgs:

View file

@ -106,7 +106,7 @@ let
nixinator.wait_for_unit("multi-user.target")
nixinator.succeed("mkdir ~/.ssh/")
nixinator.succeed("ssh-keyscan -H nixinatee >> ~/.ssh/known_hosts")
nixinator.succeed("exec ${deployScript.nixinate.nixinatee.program} >&2")
nixinator.succeed("exec ${deployScript.nixinate-nixinatee.program} >&2")
nixinatee.wait_for_unit("nginx.service")
nixinatee.wait_for_open_port("80")
with subtest("Check that Nginx webserver can be reached by deployer after deployment"):