From 76dbef54af3bbfbf81edd8a45f6ba8dea0db47f9 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 28 Sep 2020 10:48:21 -0700 Subject: stuff --- flake.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2efb943 --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + inputs = { + naersk.url = "github:nmattia/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, naersk }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk { }; + in + { + defaultPackage = naersk-lib.buildPackage ./.; + + defaultApp = { + type = "app"; + program = "${self.defaultPackage."${system}"}/bin/deploy-rs"; + }; + }); +} -- cgit v1.2.3 From 239d0f8999b47e9e76589ee1fa2d9f3459c47335 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 28 Sep 2020 15:45:53 -0700 Subject: use separate binary for activation, more cleanup --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 2efb943..acc3f18 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,7 @@ defaultApp = { type = "app"; - program = "${self.defaultPackage."${system}"}/bin/deploy-rs"; + program = "${self.defaultPackage."${system}"}/bin/deploy"; }; }); } -- cgit v1.2.3 From 8d21dd335e5259dadf832a5d1a7c72b9dd1f4400 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 29 Sep 2020 15:10:06 -0700 Subject: Add license information, reformat Nix files, clean up --- flake.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index acc3f18..d3d1817 100644 --- a/flake.nix +++ b/flake.nix @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2020 Serokell +# +# SPDX-License-Identifier: MPL-2.0 + { inputs = { naersk.url = "github:nmattia/naersk/master"; @@ -10,8 +14,7 @@ let pkgs = import nixpkgs { inherit system; }; naersk-lib = pkgs.callPackage naersk { }; - in - { + in { defaultPackage = naersk-lib.buildPackage ./.; defaultApp = { -- cgit v1.2.3 From 7c00fd2761e6efffe763ece5d08d9a6d3fb95092 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 5 Oct 2020 19:46:28 -0700 Subject: Add interface with json schema, fix flake-less issues, put setActivate and jsonSchema check in flake lib --- flake.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index d3d1817..9cfaa49 100644 --- a/flake.nix +++ b/flake.nix @@ -14,12 +14,35 @@ let pkgs = import nixpkgs { inherit system; }; naersk-lib = pkgs.callPackage naersk { }; - in { + setActivate = base: activate: pkgs.symlinkJoin { + name = ("activatable-" + base.name); + paths = [ + base + (pkgs.writeTextFile { + name = base.name + "-activate-path"; + text = '' + #!${pkgs.runtimeShell} + ${activate} + ''; + executable = true; + destination = "/activate"; + }) + ]; + }; + in + { defaultPackage = naersk-lib.buildPackage ./.; defaultApp = { type = "app"; program = "${self.defaultPackage."${system}"}/bin/deploy"; }; + + lib = { + inherit setActivate; + + checkSchema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } + "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out"; + }; }); } -- cgit v1.2.3 From 219d55e99e792a093c12dbc045bed88a4bfe1916 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Thu, 8 Oct 2020 20:01:01 -0700 Subject: Minor flake and documentation fixes --- flake.nix | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 9cfaa49..81603e4 100644 --- a/flake.nix +++ b/flake.nix @@ -3,43 +3,53 @@ # SPDX-License-Identifier: MPL-2.0 { + description = "A Simple multi-profile Nix-flake deploy tool."; + inputs = { - naersk.url = "github:nmattia/naersk/master"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + naersk = { + url = "github:nmattia/naersk/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; }; - outputs = { self, nixpkgs, utils, naersk }: + outputs = { self, nixpkgs, utils, naersk, ... }: utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; naersk-lib = pkgs.callPackage naersk { }; - setActivate = base: activate: pkgs.symlinkJoin { - name = ("activatable-" + base.name); - paths = [ - base - (pkgs.writeTextFile { - name = base.name + "-activate-path"; - text = '' - #!${pkgs.runtimeShell} - ${activate} - ''; - executable = true; - destination = "/activate"; - }) - ]; - }; in { - defaultPackage = naersk-lib.buildPackage ./.; + defaultPackage = self.packages."${system}".deploy-rs; + packages.deploy-rs = naersk-lib.buildPackage ./.; - defaultApp = { + defaultApp = self.apps."${system}".deploy-rs; + apps.deploy-rs = { type = "app"; program = "${self.defaultPackage."${system}"}/bin/deploy"; }; lib = { - inherit setActivate; + setActivate = base: activate: pkgs.symlinkJoin { + name = ("activatable-" + base.name); + paths = [ + base + (pkgs.writeTextFile { + name = base.name + "-activate-path"; + text = '' + #!${pkgs.runtimeShell} + ${activate} + ''; + executable = true; + destination = "/activate"; + }) + ]; + }; checkSchema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out"; -- cgit v1.2.3 From e463c62922ad09f016e4f1dd1d6d0cabccb0ff79 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Sun, 11 Oct 2020 15:08:02 -0700 Subject: Move activate script location, use buildEnv for setActivate --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 81603e4..73aa802 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ }; lib = { - setActivate = base: activate: pkgs.symlinkJoin { + setActivate = base: activate: pkgs.buildEnv { name = ("activatable-" + base.name); paths = [ base @@ -46,7 +46,7 @@ ${activate} ''; executable = true; - destination = "/activate"; + destination = "/deploy-rs-activate"; }) ]; }; -- cgit v1.2.3 From 8b3b91344abe6b6361b22943a0176e41fb2d585c Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 26 Oct 2020 11:29:01 -0700 Subject: Improve checks usage, add check for activation script existing --- flake.nix | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 73aa802..fe24754 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,7 @@ program = "${self.defaultPackage."${system}"}/bin/deploy"; }; - lib = { + lib = rec { setActivate = base: activate: pkgs.buildEnv { name = ("activatable-" + base.name); paths = [ @@ -51,8 +51,26 @@ ]; }; - checkSchema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } - "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out"; + # DEPRECATED + checkSchema = checks.schema; + + deployChecks = deploy: builtins.mapAttrs (_: check: check deploy) checks; + + checks = { + schema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } '' + ${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out + ''; + + activate = deploy: + let + allPaths = pkgs.lib.flatten (pkgs.lib.mapAttrsToList (nodeName: node: pkgs.lib.mapAttrsToList (profileName: profile: profile.path) node.profiles) deploy.nodes); + in + pkgs.runCommandNoCC "deploy-rs-check-activate" { } '' + for i in ${builtins.concatStringsSep " " allPaths}; do test -f "$i/deploy-rs-activate" || (echo "A profile path is missing an activation script" && exit 1); done + + touch $out + ''; + }; }; }); } -- cgit v1.2.3