From c52a09d34c350284cd87728ca2016019256f2783 Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Mon, 11 Dec 2023 21:02:13 +0100 Subject: [PATCH] Flatten apps (nixinate-name instead nixinate.name) - Solves https://git.vlt81.de/tristan/nixinate/issues/12 --- README.md | 5 ++-- flake.nix | 50 +++++++++++++++++++--------------------- tests/vmTest/default.nix | 2 +- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 96b4021..4e5c7ee 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flake.nix b/flake.nix index 4d6a4e9..ce006f1 100644 --- a/flake.nix +++ b/flake.nix @@ -118,32 +118,30 @@ in final.writeScript "deploy-${machine}.sh" script; in - { - nixinate = ( - nixpkgs.lib.genAttrs - validMachines - ( - x: { - type = "app"; - program = toString (mkDeployScript { - machine = x; - dryRun = false; - }); - } - ) - // nixpkgs.lib.genAttrs - (map (a: a + "-dry-run") validMachines) - ( - x: { - type = "app"; - program = toString (mkDeployScript { - machine = nixpkgs.lib.removeSuffix "-dry-run" x; - dryRun = true; - }); - } - ) - ); - }; + ( + nixpkgs.lib.genAttrs + (map (a: "nixinate-" + a) validMachines) + ( + x: { + type = "app"; + program = toString (mkDeployScript { + machine = nixpkgs.lib.removePrefix "nixinate-" x; + dryRun = false; + }); + } + ) + // nixpkgs.lib.genAttrs + (map (a: "nixinate-" + a + "-dry-run") validMachines) + ( + x: { + type = "app"; + program = toString (mkDeployScript { + machine = nixpkgs.lib.removePrefix "nixinate-" nixpkgs.lib.removeSuffix "-dry-run" x; + dryRun = true; + }); + } + ) + ); }; nixinate = forAllSystems (system: pkgs: nixpkgsFor.${system}.generateApps); checks = forAllSystems ( diff --git a/tests/vmTest/default.nix b/tests/vmTest/default.nix index f93ef12..73aca38 100644 --- a/tests/vmTest/default.nix +++ b/tests/vmTest/default.nix @@ -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"):