From edaed825650eea32878441d3b8c7eb40e8877882 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Mon, 28 Sep 2020 16:17:31 -0700
Subject: Add examples
---
examples/simple/flake.lock | 25 +++++++++++++++++++++
examples/simple/flake.nix | 23 ++++++++++++++++++++
examples/system/README.md | 10 +++++++++
examples/system/bare.nix | 6 +++++
examples/system/common.nix | 30 +++++++++++++++++++++++++
examples/system/configuration.nix | 11 ++++++++++
examples/system/flake.lock | 25 +++++++++++++++++++++
examples/system/flake.nix | 46 +++++++++++++++++++++++++++++++++++++++
examples/system/hello.nix | 27 +++++++++++++++++++++++
examples/system/nix-pub.pem | 1 +
examples/system/nix.key | 1 +
11 files changed, 205 insertions(+)
create mode 100644 examples/simple/flake.lock
create mode 100644 examples/simple/flake.nix
create mode 100644 examples/system/README.md
create mode 100644 examples/system/bare.nix
create mode 100644 examples/system/common.nix
create mode 100644 examples/system/configuration.nix
create mode 100644 examples/system/flake.lock
create mode 100644 examples/system/flake.nix
create mode 100644 examples/system/hello.nix
create mode 100644 examples/system/nix-pub.pem
create mode 100644 examples/system/nix.key
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
new file mode 100644
index 0000000..a57ff9d
--- /dev/null
+++ b/examples/simple/flake.lock
@@ -0,0 +1,25 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1592491430,
+ "narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "07299ff81e58e16b282fe602ce5e629854dfd544",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
new file mode 100644
index 0000000..6e516d3
--- /dev/null
+++ b/examples/simple/flake.nix
@@ -0,0 +1,23 @@
+{
+ description = "Deploy GNU hello to localhost";
+
+ outputs = { self, nixpkgs }: {
+ deploy.nodes.example = {
+ hostname = "localhost";
+ profiles.hello = {
+ user = "test_deploy";
+ path = nixpkgs.legacyPackages.x86_64-linux.hello;
+ # Just to test that it's working
+ activate = "$PROFILE/bin/hello";
+ };
+ };
+ checks = builtins.mapAttrs
+ (_: pkgs: {
+ jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
+ } ${../../interface/deploy.json} && touch $out";
+ })
+ nixpkgs.legacyPackages;
+ };
+}
diff --git a/examples/system/README.md b/examples/system/README.md
new file mode 100644
index 0000000..1dea41f
--- /dev/null
+++ b/examples/system/README.md
@@ -0,0 +1,10 @@
+# Example nixos system deployment
+
+This is an example of how to deploy a full nixos system with a separate user unit to a bare machine.
+
+1. Run bare system from `.#nixosConfigurations.bare`
+ - `nix build .#nixosConfigurations.bare.config.system.build.vm`
+ - `QEMU_NET_OPTS=hostfwd=tcp::2221-:22 ./result/bin/run-bare-system-vm`
+2. `nix run github:serokell/deploy --prime`
+3. ???
+4. PROFIT!!!
diff --git a/examples/system/bare.nix b/examples/system/bare.nix
new file mode 100644
index 0000000..282080f
--- /dev/null
+++ b/examples/system/bare.nix
@@ -0,0 +1,6 @@
+{
+ imports = [ ./common.nix ];
+
+ # Use that when deploy scripts asks you for a hostname
+ networking.hostName = "bare-system";
+}
diff --git a/examples/system/common.nix b/examples/system/common.nix
new file mode 100644
index 0000000..7e7448e
--- /dev/null
+++ b/examples/system/common.nix
@@ -0,0 +1,30 @@
+{
+ boot.loader.systemd-boot.enable = true;
+
+ fileSystems."/" = {
+ device = "/dev/disk/by-uuid/00000000-0000-0000-0000-000000000000";
+ fsType = "btrfs";
+ };
+
+ users.users.admin = {
+ isNormalUser = true;
+ extraGroups = [ "wheel" "sudo" ];
+ password = "123";
+ };
+
+ services.openssh = { enable = true; };
+
+ # Another option would be root on the server
+ security.sudo.extraRules = [{
+ groups = [ "wheel" ];
+ commands = [{
+ command = "ALL";
+ options = [ "NOPASSWD" ];
+ }];
+ }];
+
+ nix.binaryCachePublicKeys = [
+ (builtins.readFile ./nix-pub.pem)
+ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
+ ];
+}
diff --git a/examples/system/configuration.nix b/examples/system/configuration.nix
new file mode 100644
index 0000000..b2b55cf
--- /dev/null
+++ b/examples/system/configuration.nix
@@ -0,0 +1,11 @@
+{
+ imports = [ ./common.nix ];
+
+ networking.hostName = "example-nixos-syyyystem";
+
+ users.users.hello = {
+ isNormalUser = true;
+ password = "";
+ uid = 1010;
+ };
+}
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
new file mode 100644
index 0000000..a57ff9d
--- /dev/null
+++ b/examples/system/flake.lock
@@ -0,0 +1,25 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1592491430,
+ "narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "07299ff81e58e16b282fe602ce5e629854dfd544",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/examples/system/flake.nix b/examples/system/flake.nix
new file mode 100644
index 0000000..383960b
--- /dev/null
+++ b/examples/system/flake.nix
@@ -0,0 +1,46 @@
+{
+ description = "Deploy a full system with hello service as a separate profile";
+
+
+ outputs = { self, nixpkgs }: {
+ nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [ ./configuration.nix ];
+ };
+
+ nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
+ };
+
+ # This is the application we actually want to run
+ defaultPackage.x86_64-linux = import ./hello.nix nixpkgs;
+
+ deploy.nodes.example = {
+ sshOpts = [ "-p" "2221" ];
+ hostname = "localhost";
+ fastConnection = true;
+ profiles = {
+ system = {
+ sshUser = "admin";
+ activate = "$PROFILE/bin/switch-to-configuration switch";
+ path = self.nixosConfigurations.example-nixos-system.config.system.build.toplevel;
+ user = "root";
+ };
+ hello = {
+ sshUser = "hello";
+ activate = "$PROFILE/bin/activate";
+ path = self.defaultPackage.x86_64-linux;
+ user = "hello";
+ };
+ };
+ };
+
+ checks = builtins.mapAttrs (_: pkgs: {
+ jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-system" { }
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
+ } ${../../interface/deploy.json} && touch $out";
+ }) nixpkgs.legacyPackages;
+ };
+}
diff --git a/examples/system/hello.nix b/examples/system/hello.nix
new file mode 100644
index 0000000..8c207f1
--- /dev/null
+++ b/examples/system/hello.nix
@@ -0,0 +1,27 @@
+nixpkgs:
+let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ generateSystemd = type: name: config:
+ (nixpkgs.lib.nixosSystem {
+ modules = [{ systemd."${type}s".${name} = config; }];
+ system = "x86_64-linux";
+ }).config.systemd.units."${name}.${type}".text;
+
+ mkService = generateSystemd "service";
+
+ service = pkgs.writeTextFile {
+ name = "hello.service";
+ text = mkService "hello" {
+ unitConfig.WantedBy = [ "multi-user.target" ];
+ path = [ pkgs.hello ];
+ script = "hello -g lel; touch $HOME/oof";
+ };
+ };
+in
+pkgs.writeShellScriptBin "activate" ''
+ mkdir -p $HOME/.config/systemd/user
+ rm $HOME/.config/systemd/user/hello.service
+ ln -s ${service} $HOME/.config/systemd/user/hello.service
+ systemctl --user daemon-reload
+ systemctl --user restart hello
+''
diff --git a/examples/system/nix-pub.pem b/examples/system/nix-pub.pem
new file mode 100644
index 0000000..926f44c
--- /dev/null
+++ b/examples/system/nix-pub.pem
@@ -0,0 +1 @@
+cache.example.com:ic28PY7OIOQtoU282iaiizvA5WIOtYx5h6c9ePn3hDQ=
\ No newline at end of file
diff --git a/examples/system/nix.key b/examples/system/nix.key
new file mode 100644
index 0000000..9157587
--- /dev/null
+++ b/examples/system/nix.key
@@ -0,0 +1 @@
+cache.example.com:dPNdwv04QPIEpcWnGioZmX9dvaGe7GCo7BZJFymDBnSJzbw9js4g5C2hTbzaJqKLO8DlYg61jHmHpz14+feENA==
\ No newline at end of file
--
cgit v1.3.1
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
---
.gitignore | 4 +
.reuse/dep5 | 10 ++
Cargo.lock.license | 3 +
Cargo.toml | 6 +-
LICENSE | 312 ++++++++++++++++++++++++++++++++++++
LICENSES/MPL-2.0.txt | 312 ++++++++++++++++++++++++++++++++++++
README.md | 25 ++-
examples/simple/flake.lock.license | 3 +
examples/simple/flake.nix | 16 +-
examples/system/README.md | 6 +
examples/system/bare.nix | 4 +
examples/system/common.nix | 4 +
examples/system/configuration.nix | 6 +-
examples/system/flake.lock.license | 3 +
examples/system/flake.nix | 17 +-
examples/system/hello.nix | 9 +-
examples/system/nix-pub.pem.license | 3 +
examples/system/nix.key.license | 3 +
flake.lock.license | 3 +
flake.nix | 7 +-
src/activate.rs | 4 +
src/main.rs | 6 +-
src/utils/data.rs | 4 +
src/utils/deploy.rs | 4 +
src/utils/mod.rs | 4 +
src/utils/push.rs | 4 +
26 files changed, 757 insertions(+), 25 deletions(-)
create mode 100644 .reuse/dep5
create mode 100644 Cargo.lock.license
create mode 100644 LICENSE
create mode 100644 LICENSES/MPL-2.0.txt
create mode 100644 examples/simple/flake.lock.license
create mode 100644 examples/system/flake.lock.license
create mode 100644 examples/system/nix-pub.pem.license
create mode 100644 examples/system/nix.key.license
create mode 100644 flake.lock.license
(limited to 'examples')
diff --git a/.gitignore b/.gitignore
index 5a39c3d..58f5ece 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
/target
result
/examples/system/bare-system.qcow2
\ No newline at end of file
diff --git a/.reuse/dep5 b/.reuse/dep5
new file mode 100644
index 0000000..d5d6256
--- /dev/null
+++ b/.reuse/dep5
@@ -0,0 +1,10 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: deploy-rs
+Upstream-Contact: Serokell
+Source: https://github.com/serokell/deploy-rs
+
+# Sample paragraph, commented out:
+#
+# Files: src/*
+# Copyright: $YEAR $NAME <$CONTACT>
+# License: ...
diff --git a/Cargo.lock.license b/Cargo.lock.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/Cargo.lock.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 035191f..07b4144 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,11 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
[package]
name = "deploy-rs"
version = "0.1.0"
-authors = ["notgne2 "]
+authors = ["Serokell "]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..09f2798
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,312 @@
+Mozilla Public License Version 2.0
+
+ 1. Definitions
+
+1.1. "Contributor" means each individual or legal entity that creates, contributes
+to the creation of, or owns Covered Software.
+
+1.2. "Contributor Version" means the combination of the Contributions of others
+(if any) used by a Contributor and that particular Contributor's Contribution.
+
+ 1.3. "Contribution" means Covered Software of a particular Contributor.
+
+1.4. "Covered Software" means Source Code Form to which the initial Contributor
+has attached the notice in Exhibit A, the Executable Form of such Source Code
+Form, and Modifications of such Source Code Form, in each case including portions
+thereof.
+
+ 1.5. "Incompatible With Secondary Licenses" means
+
+(a) that the initial Contributor has attached the notice described in Exhibit
+B to the Covered Software; or
+
+(b) that the Covered Software was made available under the terms of version
+1.1 or earlier of the License, but not also under the terms of a Secondary
+License.
+
+1.6. "Executable Form" means any form of the work other than Source Code Form.
+
+1.7. "Larger Work" means a work that combines Covered Software with other
+material, in a separate file or files, that is not Covered Software.
+
+ 1.8. "License" means this document.
+
+1.9. "Licensable" means having the right to grant, to the maximum extent possible,
+whether at the time of the initial grant or subsequently, any and all of the
+rights conveyed by this License.
+
+ 1.10. "Modifications" means any of the following:
+
+(a) any file in Source Code Form that results from an addition to, deletion
+from, or modification of the contents of Covered Software; or
+
+(b) any new file in Source Code Form that contains any Covered Software.
+
+1.11. "Patent Claims" of a Contributor means any patent claim(s), including
+without limitation, method, process, and apparatus claims, in any patent Licensable
+by such Contributor that would be infringed, but for the grant of the License,
+by the making, using, selling, offering for sale, having made, import, or
+transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License" means either the GNU General Public License, Version
+2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General
+Public License, Version 3.0, or any later versions of those licenses.
+
+1.13. "Source Code Form" means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your") means an individual or a legal entity exercising rights
+under this License. For legal entities, "You" includes any entity that controls,
+is controlled by, or is under common control with You. For purposes of this
+definition, "control" means (a) the power, direct or indirect, to cause the
+direction or management of such entity, whether by contract or otherwise,
+or (b) ownership of more than fifty percent (50%) of the outstanding shares
+or beneficial ownership of such entity.
+
+ 2. License Grants and Conditions
+
+ 2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
+license:
+
+(a) under intellectual property rights (other than patent or trademark) Licensable
+by such Contributor to use, reproduce, make available, modify, display, perform,
+distribute, and otherwise exploit its Contributions, either on an unmodified
+basis, with Modifications, or as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer for
+sale, have made, import, and otherwise transfer either its Contributions or
+its Contributor Version.
+
+ 2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution become
+effective for each Contribution on the date the Contributor first distributes
+such Contribution.
+
+ 2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under this
+License. No additional rights or licenses will be implied from the distribution
+or licensing of Covered Software under this License. Notwithstanding Section
+2.1(b) above, no patent license is granted by a Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software; or
+
+(b) for infringements caused by: (i) Your and any other third party's modifications
+of Covered Software, or (ii) the combination of its Contributions with other
+software (except as part of its Contributor Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of its
+Contributions.
+
+This License does not grant any rights in the trademarks, service marks, or
+logos of any Contributor (except as may be necessary to comply with the notice
+requirements in Section 3.4).
+
+ 2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to distribute
+the Covered Software under a subsequent version of this License (see Section
+10.2) or under the terms of a Secondary License (if permitted under the terms
+of Section 3.3).
+
+ 2.5. Representation
+
+Each Contributor represents that the Contributor believes its Contributions
+are its original creation(s) or it has sufficient rights to grant the rights
+to its Contributions conveyed by this License.
+
+ 2.6. Fair Use
+
+This License is not intended to limit any rights You have under applicable
+copyright doctrines of fair use, fair dealing, or other equivalents.
+
+ 2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+Section 2.1.
+
+ 3. Responsibilities
+
+ 3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any Modifications
+that You create or to which You contribute, must be under the terms of this
+License. You must inform recipients that the Source Code Form of the Covered
+Software is governed by the terms of this License, and how they can obtain
+a copy of this License. You may not attempt to alter or restrict the recipients'
+rights in the Source Code Form.
+
+ 3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code Form,
+as described in Section 3.1, and You must inform recipients of the Executable
+Form how they can obtain a copy of such Source Code Form by reasonable means
+in a timely manner, at a charge no more than the cost of distribution to the
+recipient; and
+
+(b) You may distribute such Executable Form under the terms of this License,
+or sublicense it under different terms, provided that the license for the
+Executable Form does not attempt to limit or alter the recipients' rights
+in the Source Code Form under this License.
+
+ 3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice, provided
+that You also comply with the requirements of this License for the Covered
+Software. If the Larger Work is a combination of Covered Software with a work
+governed by one or more Secondary Licenses, and the Covered Software is not
+Incompatible With Secondary Licenses, this License permits You to additionally
+distribute such Covered Software under the terms of such Secondary License(s),
+so that the recipient of the Larger Work may, at their option, further distribute
+the Covered Software under the terms of either this License or such Secondary
+License(s).
+
+ 3.4. Notices
+
+You may not remove or alter the substance of any license notices (including
+copyright notices, patent notices, disclaimers of warranty, or limitations
+of liability) contained within the Source Code Form of the Covered Software,
+except that You may alter any license notices to the extent required to remedy
+known factual inaccuracies.
+
+ 3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support, indemnity
+or liability obligations to one or more recipients of Covered Software. However,
+You may do so only on Your own behalf, and not on behalf of any Contributor.
+You must make it absolutely clear that any such warranty, support, indemnity,
+or liability obligation is offered by You alone, and You hereby agree to indemnify
+every Contributor for any liability incurred by such Contributor as a result
+of warranty, support, indemnity or liability terms You offer. You may include
+additional disclaimers of warranty and limitations of liability specific to
+any jurisdiction.
+
+ 4. Inability to Comply Due to Statute or Regulation
+
+If it is impossible for You to comply with any of the terms of this License
+with respect to some or all of the Covered Software due to statute, judicial
+order, or regulation then You must: (a) comply with the terms of this License
+to the maximum extent possible; and (b) describe the limitations and the code
+they affect. Such description must be placed in a text file included with
+all distributions of the Covered Software under this License. Except to the
+extent prohibited by statute or regulation, such description must be sufficiently
+detailed for a recipient of ordinary skill to be able to understand it.
+
+ 5. Termination
+
+5.1. The rights granted under this License will terminate automatically if
+You fail to comply with any of its terms. However, if You become compliant,
+then the rights granted under this License from a particular Contributor are
+reinstated (a) provisionally, unless and until such Contributor explicitly
+and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor
+fails to notify You of the non-compliance by some reasonable means prior to
+60 days after You have come back into compliance. Moreover, Your grants from
+a particular Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the first
+time You have received notice of non-compliance with this License from such
+Contributor, and You become compliant prior to 30 days after Your receipt
+of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent infringement
+claim (excluding declaratory judgment actions, counter-claims, and cross-claims)
+alleging that a Contributor Version directly or indirectly infringes any patent,
+then the rights granted to You by any and all Contributors for the Covered
+Software under Section 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end
+user license agreements (excluding distributors and resellers) which have
+been validly granted by You or Your distributors under this License prior
+to termination shall survive termination.
+
+ 6. Disclaimer of Warranty
+
+Covered Software is provided under this License on an "as is" basis, without
+warranty of any kind, either expressed, implied, or statutory, including,
+without limitation, warranties that the Covered Software is free of defects,
+merchantable, fit for a particular purpose or non-infringing. The entire risk
+as to the quality and performance of the Covered Software is with You. Should
+any Covered Software prove defective in any respect, You (not any Contributor)
+assume the cost of any necessary servicing, repair, or correction. This disclaimer
+of warranty constitutes an essential part of this License. No use of any Covered
+Software is authorized under this License except under this disclaimer.
+
+ 7. Limitation of Liability
+
+Under no circumstances and under no legal theory, whether tort (including
+negligence), contract, or otherwise, shall any Contributor, or anyone who
+distributes Covered Software as permitted above, be liable to You for any
+direct, indirect, special, incidental, or consequential damages of any character
+including, without limitation, damages for lost profits, loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all other commercial
+damages or losses, even if such party shall have been informed of the possibility
+of such damages. This limitation of liability shall not apply to liability
+for death or personal injury resulting from such party's negligence to the
+extent applicable law prohibits such limitation. Some jurisdictions do not
+allow the exclusion or limitation of incidental or consequential damages,
+so this exclusion and limitation may not apply to You.
+
+ 8. Litigation
+
+Any litigation relating to this License may be brought only in the courts
+of a jurisdiction where the defendant maintains its principal place of business
+and such litigation shall be governed by laws of that jurisdiction, without
+reference to its conflict-of-law provisions. Nothing in this Section shall
+prevent a party's ability to bring cross-claims or counter-claims.
+
+ 9. Miscellaneous
+
+This License represents the complete agreement concerning the subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it enforceable.
+Any law or regulation which provides that the language of a contract shall
+be construed against the drafter shall not be used to construe this License
+against a Contributor.
+
+ 10. Versions of the License
+
+ 10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section 10.3,
+no one other than the license steward has the right to modify or publish new
+versions of this License. Each version will be given a distinguishing version
+number.
+
+ 10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version of
+the License under which You originally received the Covered Software, or under
+the terms of any subsequent version published by the license steward.
+
+ 10.3. Modified Versions
+
+If you create software not governed by this License, and you want to create
+a new license for such software, you may create and use a modified version
+of this License if you rename the license and remove any references to the
+name of the license steward (except to note that such modified license differs
+from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With Secondary
+Licenses under the terms of this version of the License, the notice described
+in Exhibit B of this License must be attached. Exhibit A - Source Code Form
+License Notice
+
+This Source Code Form is subject to the terms of the Mozilla Public License,
+v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain
+one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file,
+then You may include the notice in a location (such as a LICENSE file in a
+relevant directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+
+This Source Code Form is "Incompatible With Secondary Licenses", as defined
+by the Mozilla Public License, v. 2.0.
diff --git a/LICENSES/MPL-2.0.txt b/LICENSES/MPL-2.0.txt
new file mode 100644
index 0000000..09f2798
--- /dev/null
+++ b/LICENSES/MPL-2.0.txt
@@ -0,0 +1,312 @@
+Mozilla Public License Version 2.0
+
+ 1. Definitions
+
+1.1. "Contributor" means each individual or legal entity that creates, contributes
+to the creation of, or owns Covered Software.
+
+1.2. "Contributor Version" means the combination of the Contributions of others
+(if any) used by a Contributor and that particular Contributor's Contribution.
+
+ 1.3. "Contribution" means Covered Software of a particular Contributor.
+
+1.4. "Covered Software" means Source Code Form to which the initial Contributor
+has attached the notice in Exhibit A, the Executable Form of such Source Code
+Form, and Modifications of such Source Code Form, in each case including portions
+thereof.
+
+ 1.5. "Incompatible With Secondary Licenses" means
+
+(a) that the initial Contributor has attached the notice described in Exhibit
+B to the Covered Software; or
+
+(b) that the Covered Software was made available under the terms of version
+1.1 or earlier of the License, but not also under the terms of a Secondary
+License.
+
+1.6. "Executable Form" means any form of the work other than Source Code Form.
+
+1.7. "Larger Work" means a work that combines Covered Software with other
+material, in a separate file or files, that is not Covered Software.
+
+ 1.8. "License" means this document.
+
+1.9. "Licensable" means having the right to grant, to the maximum extent possible,
+whether at the time of the initial grant or subsequently, any and all of the
+rights conveyed by this License.
+
+ 1.10. "Modifications" means any of the following:
+
+(a) any file in Source Code Form that results from an addition to, deletion
+from, or modification of the contents of Covered Software; or
+
+(b) any new file in Source Code Form that contains any Covered Software.
+
+1.11. "Patent Claims" of a Contributor means any patent claim(s), including
+without limitation, method, process, and apparatus claims, in any patent Licensable
+by such Contributor that would be infringed, but for the grant of the License,
+by the making, using, selling, offering for sale, having made, import, or
+transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License" means either the GNU General Public License, Version
+2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General
+Public License, Version 3.0, or any later versions of those licenses.
+
+1.13. "Source Code Form" means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your") means an individual or a legal entity exercising rights
+under this License. For legal entities, "You" includes any entity that controls,
+is controlled by, or is under common control with You. For purposes of this
+definition, "control" means (a) the power, direct or indirect, to cause the
+direction or management of such entity, whether by contract or otherwise,
+or (b) ownership of more than fifty percent (50%) of the outstanding shares
+or beneficial ownership of such entity.
+
+ 2. License Grants and Conditions
+
+ 2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
+license:
+
+(a) under intellectual property rights (other than patent or trademark) Licensable
+by such Contributor to use, reproduce, make available, modify, display, perform,
+distribute, and otherwise exploit its Contributions, either on an unmodified
+basis, with Modifications, or as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer for
+sale, have made, import, and otherwise transfer either its Contributions or
+its Contributor Version.
+
+ 2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution become
+effective for each Contribution on the date the Contributor first distributes
+such Contribution.
+
+ 2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under this
+License. No additional rights or licenses will be implied from the distribution
+or licensing of Covered Software under this License. Notwithstanding Section
+2.1(b) above, no patent license is granted by a Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software; or
+
+(b) for infringements caused by: (i) Your and any other third party's modifications
+of Covered Software, or (ii) the combination of its Contributions with other
+software (except as part of its Contributor Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of its
+Contributions.
+
+This License does not grant any rights in the trademarks, service marks, or
+logos of any Contributor (except as may be necessary to comply with the notice
+requirements in Section 3.4).
+
+ 2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to distribute
+the Covered Software under a subsequent version of this License (see Section
+10.2) or under the terms of a Secondary License (if permitted under the terms
+of Section 3.3).
+
+ 2.5. Representation
+
+Each Contributor represents that the Contributor believes its Contributions
+are its original creation(s) or it has sufficient rights to grant the rights
+to its Contributions conveyed by this License.
+
+ 2.6. Fair Use
+
+This License is not intended to limit any rights You have under applicable
+copyright doctrines of fair use, fair dealing, or other equivalents.
+
+ 2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+Section 2.1.
+
+ 3. Responsibilities
+
+ 3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any Modifications
+that You create or to which You contribute, must be under the terms of this
+License. You must inform recipients that the Source Code Form of the Covered
+Software is governed by the terms of this License, and how they can obtain
+a copy of this License. You may not attempt to alter or restrict the recipients'
+rights in the Source Code Form.
+
+ 3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code Form,
+as described in Section 3.1, and You must inform recipients of the Executable
+Form how they can obtain a copy of such Source Code Form by reasonable means
+in a timely manner, at a charge no more than the cost of distribution to the
+recipient; and
+
+(b) You may distribute such Executable Form under the terms of this License,
+or sublicense it under different terms, provided that the license for the
+Executable Form does not attempt to limit or alter the recipients' rights
+in the Source Code Form under this License.
+
+ 3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice, provided
+that You also comply with the requirements of this License for the Covered
+Software. If the Larger Work is a combination of Covered Software with a work
+governed by one or more Secondary Licenses, and the Covered Software is not
+Incompatible With Secondary Licenses, this License permits You to additionally
+distribute such Covered Software under the terms of such Secondary License(s),
+so that the recipient of the Larger Work may, at their option, further distribute
+the Covered Software under the terms of either this License or such Secondary
+License(s).
+
+ 3.4. Notices
+
+You may not remove or alter the substance of any license notices (including
+copyright notices, patent notices, disclaimers of warranty, or limitations
+of liability) contained within the Source Code Form of the Covered Software,
+except that You may alter any license notices to the extent required to remedy
+known factual inaccuracies.
+
+ 3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support, indemnity
+or liability obligations to one or more recipients of Covered Software. However,
+You may do so only on Your own behalf, and not on behalf of any Contributor.
+You must make it absolutely clear that any such warranty, support, indemnity,
+or liability obligation is offered by You alone, and You hereby agree to indemnify
+every Contributor for any liability incurred by such Contributor as a result
+of warranty, support, indemnity or liability terms You offer. You may include
+additional disclaimers of warranty and limitations of liability specific to
+any jurisdiction.
+
+ 4. Inability to Comply Due to Statute or Regulation
+
+If it is impossible for You to comply with any of the terms of this License
+with respect to some or all of the Covered Software due to statute, judicial
+order, or regulation then You must: (a) comply with the terms of this License
+to the maximum extent possible; and (b) describe the limitations and the code
+they affect. Such description must be placed in a text file included with
+all distributions of the Covered Software under this License. Except to the
+extent prohibited by statute or regulation, such description must be sufficiently
+detailed for a recipient of ordinary skill to be able to understand it.
+
+ 5. Termination
+
+5.1. The rights granted under this License will terminate automatically if
+You fail to comply with any of its terms. However, if You become compliant,
+then the rights granted under this License from a particular Contributor are
+reinstated (a) provisionally, unless and until such Contributor explicitly
+and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor
+fails to notify You of the non-compliance by some reasonable means prior to
+60 days after You have come back into compliance. Moreover, Your grants from
+a particular Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the first
+time You have received notice of non-compliance with this License from such
+Contributor, and You become compliant prior to 30 days after Your receipt
+of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent infringement
+claim (excluding declaratory judgment actions, counter-claims, and cross-claims)
+alleging that a Contributor Version directly or indirectly infringes any patent,
+then the rights granted to You by any and all Contributors for the Covered
+Software under Section 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end
+user license agreements (excluding distributors and resellers) which have
+been validly granted by You or Your distributors under this License prior
+to termination shall survive termination.
+
+ 6. Disclaimer of Warranty
+
+Covered Software is provided under this License on an "as is" basis, without
+warranty of any kind, either expressed, implied, or statutory, including,
+without limitation, warranties that the Covered Software is free of defects,
+merchantable, fit for a particular purpose or non-infringing. The entire risk
+as to the quality and performance of the Covered Software is with You. Should
+any Covered Software prove defective in any respect, You (not any Contributor)
+assume the cost of any necessary servicing, repair, or correction. This disclaimer
+of warranty constitutes an essential part of this License. No use of any Covered
+Software is authorized under this License except under this disclaimer.
+
+ 7. Limitation of Liability
+
+Under no circumstances and under no legal theory, whether tort (including
+negligence), contract, or otherwise, shall any Contributor, or anyone who
+distributes Covered Software as permitted above, be liable to You for any
+direct, indirect, special, incidental, or consequential damages of any character
+including, without limitation, damages for lost profits, loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all other commercial
+damages or losses, even if such party shall have been informed of the possibility
+of such damages. This limitation of liability shall not apply to liability
+for death or personal injury resulting from such party's negligence to the
+extent applicable law prohibits such limitation. Some jurisdictions do not
+allow the exclusion or limitation of incidental or consequential damages,
+so this exclusion and limitation may not apply to You.
+
+ 8. Litigation
+
+Any litigation relating to this License may be brought only in the courts
+of a jurisdiction where the defendant maintains its principal place of business
+and such litigation shall be governed by laws of that jurisdiction, without
+reference to its conflict-of-law provisions. Nothing in this Section shall
+prevent a party's ability to bring cross-claims or counter-claims.
+
+ 9. Miscellaneous
+
+This License represents the complete agreement concerning the subject matter
+hereof. If any provision of this License is held to be unenforceable, such
+provision shall be reformed only to the extent necessary to make it enforceable.
+Any law or regulation which provides that the language of a contract shall
+be construed against the drafter shall not be used to construe this License
+against a Contributor.
+
+ 10. Versions of the License
+
+ 10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section 10.3,
+no one other than the license steward has the right to modify or publish new
+versions of this License. Each version will be given a distinguishing version
+number.
+
+ 10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version of
+the License under which You originally received the Covered Software, or under
+the terms of any subsequent version published by the license steward.
+
+ 10.3. Modified Versions
+
+If you create software not governed by this License, and you want to create
+a new license for such software, you may create and use a modified version
+of this License if you rename the license and remove any references to the
+name of the license steward (except to note that such modified license differs
+from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With Secondary
+Licenses under the terms of this version of the License, the notice described
+in Exhibit B of this License must be attached. Exhibit A - Source Code Form
+License Notice
+
+This Source Code Form is subject to the terms of the Mozilla Public License,
+v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain
+one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file,
+then You may include the notice in a location (such as a LICENSE file in a
+relevant directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+
+This Source Code Form is "Incompatible With Secondary Licenses", as defined
+by the Mozilla Public License, v. 2.0.
diff --git a/README.md b/README.md
index 4580a42..74b96be 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,26 @@
+
+
# deploy-rs
-#### A candidate for [serokell/deploy](https://github.com/serokell/deploy)
+
+A Simple multi-profile Nix-flake deploy tool.
**This is very early development software, you should expect to find issues**
-## Usage examples
+## Usage
-Example Nix expressions/configurations are in the [examples folder](./examples), here are various ways to deploy
- `nix run github:notgne2/deploy-rs your-flake#node.profile`
- `nix run github:notgne2/deploy-rs your-flake#node`
- `nix run github:notgne2/deploy-rs your-flake`
+## API
+
+Example Nix expressions/configurations are in the [examples folder](./examples).
+
## Idea
`deploy-rs` is a simple Rust program that will take a Nix flake and use it to deploy any of your defined profiles to your nodes. This is _strongly_ based off of [serokell/deploy](https://github.com/serokell/deploy), with the intention of eventually replacing it.
@@ -21,4 +31,11 @@ This type of design (as opposed to more traditional tools like NixOps or morph)
- ~~Ordered profiles~~
- Automatic rollbacks if one profile on node failed to deploy (partially implemented)
-- UI (?)
\ No newline at end of file
+- UI (?)
+
+## About Serokell
+
+deploy-rs is maintained and funded with ❤️ by [Serokell](https://serokell.io/).
+The names and logo for Serokell are trademark of Serokell OÜ.
+
+We love open source software! See [our other projects](https://serokell.io/community?utm_source=github) or [hire us](https://serokell.io/hire-us?utm_source=github) to design, develop and grow your idea!
\ No newline at end of file
diff --git a/examples/simple/flake.lock.license b/examples/simple/flake.lock.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/examples/simple/flake.lock.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
index 6e516d3..800363f 100644
--- a/examples/simple/flake.nix
+++ b/examples/simple/flake.nix
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
{
description = "Deploy GNU hello to localhost";
@@ -5,19 +9,17 @@
deploy.nodes.example = {
hostname = "localhost";
profiles.hello = {
- user = "test_deploy";
+ user = "balsoft";
path = nixpkgs.legacyPackages.x86_64-linux.hello;
# Just to test that it's working
activate = "$PROFILE/bin/hello";
};
};
- checks = builtins.mapAttrs
- (_: pkgs: {
- jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ checks = builtins.mapAttrs (_: pkgs: {
+ jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
} ${../../interface/deploy.json} && touch $out";
- })
- nixpkgs.legacyPackages;
+ }) nixpkgs.legacyPackages;
};
}
diff --git a/examples/system/README.md b/examples/system/README.md
index 1dea41f..daf649a 100644
--- a/examples/system/README.md
+++ b/examples/system/README.md
@@ -1,3 +1,9 @@
+
+
# Example nixos system deployment
This is an example of how to deploy a full nixos system with a separate user unit to a bare machine.
diff --git a/examples/system/bare.nix b/examples/system/bare.nix
index 282080f..46ba3b2 100644
--- a/examples/system/bare.nix
+++ b/examples/system/bare.nix
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
{
imports = [ ./common.nix ];
diff --git a/examples/system/common.nix b/examples/system/common.nix
index 7e7448e..83ea225 100644
--- a/examples/system/common.nix
+++ b/examples/system/common.nix
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
{
boot.loader.systemd-boot.enable = true;
diff --git a/examples/system/configuration.nix b/examples/system/configuration.nix
index b2b55cf..6d4234a 100644
--- a/examples/system/configuration.nix
+++ b/examples/system/configuration.nix
@@ -1,7 +1,11 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
{
imports = [ ./common.nix ];
- networking.hostName = "example-nixos-syyyystem";
+ networking.hostName = "example-nixos-system";
users.users.hello = {
isNormalUser = true;
diff --git a/examples/system/flake.lock.license b/examples/system/flake.lock.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/examples/system/flake.lock.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
diff --git a/examples/system/flake.nix b/examples/system/flake.nix
index 383960b..5179258 100644
--- a/examples/system/flake.nix
+++ b/examples/system/flake.nix
@@ -1,7 +1,10 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
{
description = "Deploy a full system with hello service as a separate profile";
-
outputs = { self, nixpkgs }: {
nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
@@ -10,7 +13,8 @@
nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
- modules = [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
+ modules =
+ [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
};
# This is the application we actually want to run
@@ -24,7 +28,8 @@
system = {
sshUser = "admin";
activate = "$PROFILE/bin/switch-to-configuration switch";
- path = self.nixosConfigurations.example-nixos-system.config.system.build.toplevel;
+ path =
+ self.nixosConfigurations.example-nixos-system.config.system.build.toplevel;
user = "root";
};
hello = {
@@ -38,9 +43,9 @@
checks = builtins.mapAttrs (_: pkgs: {
jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-system" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
- pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
- } ${../../interface/deploy.json} && touch $out";
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
+ } ${../../interface/deploy.json} && touch $out";
}) nixpkgs.legacyPackages;
};
}
diff --git a/examples/system/hello.nix b/examples/system/hello.nix
index 8c207f1..df57308 100644
--- a/examples/system/hello.nix
+++ b/examples/system/hello.nix
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 Serokell
+#
+# SPDX-License-Identifier: MPL-2.0
+
nixpkgs:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
@@ -14,11 +18,10 @@ let
text = mkService "hello" {
unitConfig.WantedBy = [ "multi-user.target" ];
path = [ pkgs.hello ];
- script = "hello -g lel; touch $HOME/oof";
+ script = "hello";
};
};
-in
-pkgs.writeShellScriptBin "activate" ''
+in pkgs.writeShellScriptBin "activate" ''
mkdir -p $HOME/.config/systemd/user
rm $HOME/.config/systemd/user/hello.service
ln -s ${service} $HOME/.config/systemd/user/hello.service
diff --git a/examples/system/nix-pub.pem.license b/examples/system/nix-pub.pem.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/examples/system/nix-pub.pem.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
diff --git a/examples/system/nix.key.license b/examples/system/nix.key.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/examples/system/nix.key.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
diff --git a/flake.lock.license b/flake.lock.license
new file mode 100644
index 0000000..9e9897d
--- /dev/null
+++ b/flake.lock.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2020 Serokell
+
+SPDX-License-Identifier: MPL-2.0
\ No newline at end of file
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 = {
diff --git a/src/activate.rs b/src/activate.rs
index 8e22aea..3c7c16d 100644
--- a/src/activate.rs
+++ b/src/activate.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use clap::Clap;
use std::process::Stdio;
diff --git a/src/main.rs b/src/main.rs
index 668b697..9e50674 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use clap::Clap;
use std::process::Stdio;
@@ -17,7 +21,7 @@ mod utils;
/// Simple Rust rewrite of a simple Nix Flake deployment tool
#[derive(Clap, Debug)]
-#[clap(version = "1.0", author = "notgne2 ")]
+#[clap(version = "1.0", author = "Serokell ")]
struct Opts {
/// The flake to deploy
#[clap(default_value = ".")]
diff --git a/src/utils/data.rs b/src/utils/data.rs
index 0753508..d1dae5b 100644
--- a/src/utils/data.rs
+++ b/src/utils/data.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use merge::Merge;
use std::collections::HashMap;
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs
index 42bd0b4..247d5e5 100644
--- a/src/utils/deploy.rs
+++ b/src/utils/deploy.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use super::data;
use tokio::process::Command;
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 8861692..5802627 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use std::borrow::Cow;
use std::path::PathBuf;
diff --git a/src/utils/push.rs b/src/utils/push.rs
index 0e1b9ba..c87c32b 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2020 Serokell
+//
+// SPDX-License-Identifier: MPL-2.0
+
use super::data;
use std::process::Stdio;
--
cgit v1.3.1
From 5674670a59168fb05f26e5b4fb41dd2662810e94 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Fri, 2 Oct 2020 12:58:11 -0700
Subject: General improvements, deprecate `activate` profile option in favor of
executing $PROFILE/activate (Wrap It Yourself) to ensure successful rollback
activations
---
examples/simple/flake.nix | 47 +++++++++----
examples/system/flake.nix | 88 ++++++++++++++----------
src/activate.rs | 168 ++++++++++++++++++++++------------------------
src/utils/data.rs | 1 -
src/utils/deploy.rs | 40 +++++------
src/utils/push.rs | 5 --
6 files changed, 183 insertions(+), 166 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
index 800363f..f53352b 100644
--- a/examples/simple/flake.nix
+++ b/examples/simple/flake.nix
@@ -5,21 +5,40 @@
{
description = "Deploy GNU hello to localhost";
- outputs = { self, nixpkgs }: {
- deploy.nodes.example = {
- hostname = "localhost";
- profiles.hello = {
- user = "balsoft";
- path = nixpkgs.legacyPackages.x86_64-linux.hello;
- # Just to test that it's working
- activate = "$PROFILE/bin/hello";
+ outputs = { self, nixpkgs }:
+ let
+ setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
+ name = ("activatable-" + base.name);
+ paths = [
+ base
+ (nixpkgs.legacyPackages.x86_64-linux.writeTextFile {
+ name = base.name + "-activate-path";
+ text = ''
+ #!${nixpkgs.legacyPackages.x86_64-linux.runtimeShell}
+ ${activate}
+ '';
+ executable = true;
+ destination = "/activate";
+ })
+ ];
};
- };
- checks = builtins.mapAttrs (_: pkgs: {
- jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ in
+ {
+
+ deploy.nodes.example = {
+ hostname = "localhost";
+ profiles.hello = {
+ user = "balsoft";
+ path = setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
+ };
+ };
+ checks = builtins.mapAttrs
+ (_: pkgs: {
+ jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
} ${../../interface/deploy.json} && touch $out";
- }) nixpkgs.legacyPackages;
- };
+ })
+ nixpkgs.legacyPackages;
+ };
}
diff --git a/examples/system/flake.nix b/examples/system/flake.nix
index 5179258..68cf3ce 100644
--- a/examples/system/flake.nix
+++ b/examples/system/flake.nix
@@ -5,47 +5,65 @@
{
description = "Deploy a full system with hello service as a separate profile";
- outputs = { self, nixpkgs }: {
- nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
- system = "x86_64-linux";
- modules = [ ./configuration.nix ];
- };
+ outputs = { self, nixpkgs }:
+ let
+ setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
+ name = ("activatable-" + base.name);
+ paths = [
+ base
+ (nixpkgs.legacyPackages.x86_64-linux.writeTextFile {
+ name = base.name + "-activate-path";
+ text = ''
+ #!${nixpkgs.legacyPackages.x86_64-linux.runtimeShell}
+ ${activate}
+ '';
+ executable = true;
+ destination = "/activate";
+ })
+ ];
+ };
+ in
+ {
+ nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [ ./configuration.nix ];
+ };
- nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
- system = "x86_64-linux";
- modules =
- [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
- };
+ nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules =
+ [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
+ };
- # This is the application we actually want to run
- defaultPackage.x86_64-linux = import ./hello.nix nixpkgs;
+ # This is the application we actually want to run
+ defaultPackage.x86_64-linux = import ./hello.nix nixpkgs;
- deploy.nodes.example = {
- sshOpts = [ "-p" "2221" ];
- hostname = "localhost";
- fastConnection = true;
- profiles = {
- system = {
- sshUser = "admin";
- activate = "$PROFILE/bin/switch-to-configuration switch";
- path =
- self.nixosConfigurations.example-nixos-system.config.system.build.toplevel;
- user = "root";
- };
- hello = {
- sshUser = "hello";
- activate = "$PROFILE/bin/activate";
- path = self.defaultPackage.x86_64-linux;
- user = "hello";
+ deploy.nodes.example = {
+ sshOpts = [ "-p" "2221" ];
+ hostname = "localhost";
+ fastConnection = true;
+ profiles = {
+ system = {
+ sshUser = "admin";
+ path =
+ setActivate self.nixosConfigurations.example-nixos-system.config.system.build.toplevel "./bin/switch-to-configuration switch";
+ user = "root";
+ };
+ hello = {
+ sshUser = "hello";
+ path = setActivate self.defaultPackage.x86_64-linux "./bin/activate";
+ user = "hello";
+ };
};
};
- };
- checks = builtins.mapAttrs (_: pkgs: {
- jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-system" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
+ checks = builtins.mapAttrs
+ (_: pkgs: {
+ jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-system" { }
+ "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
} ${../../interface/deploy.json} && touch $out";
- }) nixpkgs.legacyPackages;
- };
+ })
+ nixpkgs.legacyPackages;
+ };
}
diff --git a/src/activate.rs b/src/activate.rs
index f75303f..64baa4f 100644
--- a/src/activate.rs
+++ b/src/activate.rs
@@ -26,10 +26,6 @@ struct Opts {
profile_path: String,
closure: String,
- /// Command for activating the given profile
- #[clap(long)]
- activate_cmd: Option,
-
/// Command for bootstrapping
#[clap(long)]
bootstrap_cmd: Option,
@@ -42,21 +38,24 @@ struct Opts {
pub async fn activate(
profile_path: String,
closure: String,
- activate_cmd: Option,
bootstrap_cmd: Option,
auto_rollback: bool,
) -> Result<(), Box> {
info!("Activating profile");
- Command::new("nix-env")
+ let nix_env_set_exit_status = Command::new("nix-env")
.arg("-p")
.arg(&profile_path)
.arg("--set")
.arg(&closure)
.stdout(Stdio::null())
- .spawn()?
+ .status()
.await?;
+ if !nix_env_set_exit_status.success() {
+ good_panic!("Failed to update nix-env generation");
+ }
+
if let (Some(bootstrap_cmd), false) = (bootstrap_cmd, !Path::new(&profile_path).exists()) {
let bootstrap_status = Command::new("bash")
.arg("-c")
@@ -76,87 +75,85 @@ pub async fn activate(
}
}
- if let Some(activate_cmd) = activate_cmd {
- let activate_status = Command::new("bash")
- .arg("-c")
- .arg(&activate_cmd)
- .env("PROFILE", &profile_path)
- .status()
- .await;
+ let activate_status = Command::new(format!("{}/activate", profile_path))
+ .env("PROFILE", &profile_path)
+ .status()
+ .await;
+
+ match activate_status {
+ Ok(s) if s.success() => (),
+ _ if auto_rollback => {
+ error!("Failed to execute activation command");
+
+ let nix_env_rollback_exit_status = Command::new("nix-env")
+ .arg("-p")
+ .arg(&profile_path)
+ .arg("--rollback")
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .await?;
+
+ if !nix_env_rollback_exit_status.success() {
+ good_panic!("`nix-env --rollback` failed");
+ }
- match activate_status {
- Ok(s) if s.success() => (),
- _ if auto_rollback => {
- error!("Failed to execute activation command");
-
- let nix_env_rollback_exit_status = Command::new("nix-env")
- .arg("-p")
- .arg(&profile_path)
- .arg("--rollback")
- .stdout(Stdio::null())
- .stderr(Stdio::null())
- .status()
- .await?;
-
- if !nix_env_rollback_exit_status.success() {
- good_panic!("`nix-env --rollback` failed");
- }
-
- let nix_env_list_generations_out = Command::new("nix-env")
- .arg("-p")
- .arg(&profile_path)
- .arg("--list-generations")
- .output()
- .await?;
-
- if !nix_env_list_generations_out.status.success() {
- good_panic!("Listing `nix-env` generations failed");
- }
-
- let generations_list = String::from_utf8(nix_env_list_generations_out.stdout)?;
-
- let last_generation_line = generations_list
- .lines()
- .last()
- .expect("Expected to find a generation in list");
-
- let last_generation_id = last_generation_line
- .split_whitespace()
- .next()
- .expect("Expected to get ID from generation entry");
-
- debug!("Removing generation entry {}", last_generation_line);
- warn!("Removing generation by ID {}", last_generation_id);
-
- let nix_env_delete_generation_exit_status = Command::new("nix-env")
- .arg("-p")
- .arg(&profile_path)
- .arg("--delete-generations")
- .arg(last_generation_id)
- .stdout(Stdio::null())
- .stderr(Stdio::null())
- .status()
- .await?;
-
- if !nix_env_delete_generation_exit_status.success() {
- good_panic!("Failed to delete failed generation");
- }
-
- // TODO: Find some way to make sure this command never changes, otherwise this will not work
- let re_activate_exit_status = Command::new("bash")
- .arg("-c")
- .arg(&activate_cmd)
- .status()
- .await?;
-
- if !re_activate_exit_status.success() {
- good_panic!("Failed to re-activate the last generation");
- }
-
- std::process::exit(1);
+ debug!("Listing generations");
+
+ let nix_env_list_generations_out = Command::new("nix-env")
+ .arg("-p")
+ .arg(&profile_path)
+ .arg("--list-generations")
+ .output()
+ .await?;
+
+ if !nix_env_list_generations_out.status.success() {
+ good_panic!("Listing `nix-env` generations failed");
}
- _ => {}
+
+ let generations_list = String::from_utf8(nix_env_list_generations_out.stdout)?;
+
+ let last_generation_line = generations_list
+ .lines()
+ .last()
+ .expect("Expected to find a generation in list");
+
+ let last_generation_id = last_generation_line
+ .split_whitespace()
+ .next()
+ .expect("Expected to get ID from generation entry");
+
+ debug!("Removing generation entry {}", last_generation_line);
+ warn!("Removing generation by ID {}", last_generation_id);
+
+ let nix_env_delete_generation_exit_status = Command::new("nix-env")
+ .arg("-p")
+ .arg(&profile_path)
+ .arg("--delete-generations")
+ .arg(last_generation_id)
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .await?;
+
+ if !nix_env_delete_generation_exit_status.success() {
+ good_panic!("Failed to delete failed generation");
+ }
+
+ info!("Attempting re-activate last generation");
+
+ let re_activate_exit_status = Command::new(format!("{}/activate", profile_path))
+ .env("PROFILE", &profile_path)
+ .status()
+ .await?;
+
+ if !re_activate_exit_status.success() {
+ good_panic!("Failed to re-activate the last generation");
+ }
+
+ std::process::exit(1);
}
+ _ => {}
}
Ok(())
@@ -175,7 +172,6 @@ async fn main() -> Result<(), Box> {
activate(
opts.profile_path,
opts.closure,
- opts.activate_cmd,
opts.bootstrap_cmd,
opts.auto_rollback,
)
diff --git a/src/utils/data.rs b/src/utils/data.rs
index d1dae5b..de6adfc 100644
--- a/src/utils/data.rs
+++ b/src/utils/data.rs
@@ -34,7 +34,6 @@ pub struct NodeSettings {
#[derive(Deserialize, Debug, Clone)]
pub struct ProfileSettings {
pub path: String,
- pub activate: Option,
pub bootstrap: Option,
}
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs
index f1f4210..7301967 100644
--- a/src/utils/deploy.rs
+++ b/src/utils/deploy.rs
@@ -9,10 +9,9 @@ fn build_activate_command(
sudo: &Option,
profile_path: &str,
closure: &str,
- activate_cmd: &Option,
bootstrap_cmd: &Option,
auto_rollback: bool,
-) -> Result> {
+) -> String {
let mut self_activate_command =
format!("{} '{}' '{}'", activate_path_str, profile_path, closure);
@@ -27,18 +26,11 @@ fn build_activate_command(
);
}
- if let Some(ref activate_cmd) = activate_cmd {
- self_activate_command = format!(
- "{} --activate-cmd '{}'",
- self_activate_command, activate_cmd
- );
- }
-
if auto_rollback {
self_activate_command = format!("{} --auto-rollback", self_activate_command);
}
- Ok(self_activate_command)
+ self_activate_command
}
#[test]
@@ -47,22 +39,21 @@ fn test_activation_command_builder() {
let sudo = Some("sudo -u test".to_string());
let profile_path = "/blah/profiles/test";
let closure = "/blah/etc";
- let activate_cmd = Some("$THING/bin/aaaaaaa".to_string());
let bootstrap_cmd = None;
let auto_rollback = true;
- match build_activate_command(
- activate_path_str,
- &sudo,
- profile_path,
- closure,
- &activate_cmd,
- &bootstrap_cmd,
- auto_rollback,
- ) {
- Err(_) => panic!(""),
- Ok(x) => assert_eq!(x, "sudo -u test /blah/bin/activate '/blah/profiles/test' '/blah/etc' --activate-cmd '$THING/bin/aaaaaaa' --auto-rollback".to_string()),
- }
+ assert_eq!(
+ build_activate_command(
+ activate_path_str,
+ &sudo,
+ profile_path,
+ closure,
+ &bootstrap_cmd,
+ auto_rollback,
+ ),
+ "sudo -u test /blah/bin/activate '/blah/profiles/test' '/blah/etc' --auto-rollback"
+ .to_string(),
+ );
}
pub async fn deploy_profile(
@@ -81,10 +72,9 @@ pub async fn deploy_profile(
&deploy_defs.sudo,
&deploy_defs.profile_path,
&deploy_data.profile.profile_settings.path,
- &deploy_data.profile.profile_settings.activate,
&deploy_data.profile.profile_settings.bootstrap,
deploy_data.merged_settings.auto_rollback,
- )?;
+ );
let hostname = match deploy_data.cmd_overrides.hostname {
Some(ref x) => x,
diff --git a/src/utils/push.rs b/src/utils/push.rs
index a973572..3f48d68 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -17,11 +17,6 @@ pub async fn push_profile(
deploy_data.profile_name, deploy_data.node_name
);
- debug!(
- "Building profile `{} for node `{}`",
- deploy_data.profile_name, deploy_data.node_name
- );
-
let build_exit_status = if supports_flakes {
Command::new("nix")
.arg("build")
--
cgit v1.3.1
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
---
examples/simple/flake.lock | 85 ++++++++++++++++++++++++++++++++++++-
examples/simple/flake.nix | 16 +++----
examples/system/flake.lock | 85 ++++++++++++++++++++++++++++++++++++-
examples/system/flake.nix | 87 ++++++++++++++------------------------
flake.nix | 25 ++++++++++-
interface/README.md | 32 ++++++++++++++
interface/deploy.json | 103 +++++++++++++++++++++++++++++++++++++++++++++
src/main.rs | 9 ++--
8 files changed, 371 insertions(+), 71 deletions(-)
create mode 100644 interface/README.md
create mode 100644 interface/deploy.json
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index a57ff9d..7791c84 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -1,6 +1,73 @@
{
"nodes": {
+ "deploy-rs": {
+ "inputs": {
+ "naersk": "naersk",
+ "nixpkgs": "nixpkgs_2",
+ "utils": "utils"
+ },
+ "locked": {
+ "lastModified": 1601668691,
+ "narHash": "sha256-1mWf71DPRNgTIUKJ4Dy+CjoyZo4JkPdrwjYJy2UzqZE=",
+ "type": "git",
+ "url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
+ },
+ "original": {
+ "owner": "serokell",
+ "repo": "deploy-rs",
+ "type": "github"
+ }
+ },
+ "naersk": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1597138680,
+ "narHash": "sha256-3pDN/W17wjVDbrkgo60xQSb24+QAPQ7ulsUq5atNni0=",
+ "owner": "nmattia",
+ "repo": "naersk",
+ "rev": "529e910a3f423a8211f8739290014b754b2555b6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nmattia",
+ "ref": "master",
+ "repo": "naersk",
+ "type": "github"
+ }
+ },
"nixpkgs": {
+ "locked": {
+ "lastModified": 1601091160,
+ "narHash": "sha256-26UI9LGjRO8Sv253zJZkoapP260QkJPQ2+vRyC1i+kI=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "2768436826543af2b1540e4fe6b5afa15850e155",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1600387253,
+ "narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "72b9660dc18ba347f7cd41a9504fc181a6d87dc3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_3": {
"locked": {
"lastModified": 1592491430,
"narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
@@ -16,7 +83,23 @@
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs"
+ "deploy-rs": "deploy-rs",
+ "nixpkgs": "nixpkgs_3"
+ }
+ },
+ "utils": {
+ "locked": {
+ "lastModified": 1600209923,
+ "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
}
}
},
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
index f53352b..d44b888 100644
--- a/examples/simple/flake.nix
+++ b/examples/simple/flake.nix
@@ -5,7 +5,9 @@
{
description = "Deploy GNU hello to localhost";
- outputs = { self, nixpkgs }:
+ inputs.deploy-rs.url = "github:serokell/deploy-rs";
+
+ outputs = { self, nixpkgs, deploy-rs }:
let
setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
name = ("activatable-" + base.name);
@@ -29,16 +31,10 @@
hostname = "localhost";
profiles.hello = {
user = "balsoft";
- path = setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
+ path = deploy-rs.lib.x86_64-linux.setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
};
};
- checks = builtins.mapAttrs
- (_: pkgs: {
- jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
- pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
- } ${../../interface/deploy.json} && touch $out";
- })
- nixpkgs.legacyPackages;
+
+ checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
};
}
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index a57ff9d..d3e489a 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -1,6 +1,73 @@
{
"nodes": {
+ "deploy-rs": {
+ "inputs": {
+ "naersk": "naersk",
+ "nixpkgs": "nixpkgs_2",
+ "utils": "utils"
+ },
+ "locked": {
+ "lastModified": 1601668691,
+ "narHash": "sha256-HvzPMsgSOQfCRoPtkwLRv09CkNjOsLHjcZtyHF+8Zbs=",
+ "type": "git",
+ "url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
+ },
+ "original": {
+ "owner": "serokell",
+ "repo": "deploy-rs",
+ "type": "github"
+ }
+ },
+ "naersk": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1597138680,
+ "narHash": "sha256-3pDN/W17wjVDbrkgo60xQSb24+QAPQ7ulsUq5atNni0=",
+ "owner": "nmattia",
+ "repo": "naersk",
+ "rev": "529e910a3f423a8211f8739290014b754b2555b6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nmattia",
+ "ref": "master",
+ "repo": "naersk",
+ "type": "github"
+ }
+ },
"nixpkgs": {
+ "locked": {
+ "lastModified": 1601091160,
+ "narHash": "sha256-26UI9LGjRO8Sv253zJZkoapP260QkJPQ2+vRyC1i+kI=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "2768436826543af2b1540e4fe6b5afa15850e155",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1600387253,
+ "narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "72b9660dc18ba347f7cd41a9504fc181a6d87dc3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_3": {
"locked": {
"lastModified": 1592491430,
"narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
@@ -16,7 +83,23 @@
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs"
+ "deploy-rs": "deploy-rs",
+ "nixpkgs": "nixpkgs_3"
+ }
+ },
+ "utils": {
+ "locked": {
+ "lastModified": 1600209923,
+ "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
}
}
},
diff --git a/examples/system/flake.nix b/examples/system/flake.nix
index 68cf3ce..32fefa1 100644
--- a/examples/system/flake.nix
+++ b/examples/system/flake.nix
@@ -5,65 +5,42 @@
{
description = "Deploy a full system with hello service as a separate profile";
- outputs = { self, nixpkgs }:
- let
- setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
- name = ("activatable-" + base.name);
- paths = [
- base
- (nixpkgs.legacyPackages.x86_64-linux.writeTextFile {
- name = base.name + "-activate-path";
- text = ''
- #!${nixpkgs.legacyPackages.x86_64-linux.runtimeShell}
- ${activate}
- '';
- executable = true;
- destination = "/activate";
- })
- ];
- };
- in
- {
- nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
- system = "x86_64-linux";
- modules = [ ./configuration.nix ];
- };
+ inputs.deploy-rs.url = "github:serokell/deploy-rs";
- nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
- system = "x86_64-linux";
- modules =
- [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
- };
+ outputs = { self, nixpkgs, deploy-rs }: {
+ nixosConfigurations.example-nixos-system = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules = [ ./configuration.nix ];
+ };
- # This is the application we actually want to run
- defaultPackage.x86_64-linux = import ./hello.nix nixpkgs;
+ nixosConfigurations.bare = nixpkgs.lib.nixosSystem {
+ system = "x86_64-linux";
+ modules =
+ [ ./bare.nix "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" ];
+ };
- deploy.nodes.example = {
- sshOpts = [ "-p" "2221" ];
- hostname = "localhost";
- fastConnection = true;
- profiles = {
- system = {
- sshUser = "admin";
- path =
- setActivate self.nixosConfigurations.example-nixos-system.config.system.build.toplevel "./bin/switch-to-configuration switch";
- user = "root";
- };
- hello = {
- sshUser = "hello";
- path = setActivate self.defaultPackage.x86_64-linux "./bin/activate";
- user = "hello";
- };
+ # This is the application we actually want to run
+ defaultPackage.x86_64-linux = import ./hello.nix nixpkgs;
+
+ deploy.nodes.example = {
+ sshOpts = [ "-p" "2221" ];
+ hostname = "localhost";
+ fastConnection = true;
+ profiles = {
+ system = {
+ sshUser = "admin";
+ path =
+ deploy-rs.lib.x86_64-linux.setActivate self.nixosConfigurations.example-nixos-system.config.system.build.toplevel "./bin/switch-to-configuration switch";
+ user = "root";
+ };
+ hello = {
+ sshUser = "hello";
+ path = deploy-rs.lib.x86_64-linux.setActivate self.defaultPackage.x86_64-linux "./bin/activate";
+ user = "hello";
};
};
-
- checks = builtins.mapAttrs
- (_: pkgs: {
- jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-system" { }
- "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
- pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
- } ${../../interface/deploy.json} && touch $out";
- })
- nixpkgs.legacyPackages;
};
+
+ checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
+ };
}
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";
+ };
});
}
diff --git a/interface/README.md b/interface/README.md
new file mode 100644
index 0000000..c6b52bd
--- /dev/null
+++ b/interface/README.md
@@ -0,0 +1,32 @@
+A flake must have a `deploy` output with the following structure:
+
+```
+deploy
+├──
+└── nodes
+ ├──
+ │ ├──
+ │ ├── hostname
+ │ └── profiles
+ │ ├──
+ │ │ ├──
+ │ │ ├── bootstrap
+ │ │ └── path
+ │ └── ...
+ └── ...
+
+```
+
+Where `` are all optional and can be one or multiple of:
+
+- `sshUser` -- user to connect as
+- `user` -- user to install and activate profiles with
+- `sshOpts` -- options passed to `nix copy` and `ssh`
+- `fastConnection` -- whether the connection from this host to the target one is fast (if it is, don't substitute on target and copy the entire closure) [default: `false`]
+- `autoRollback` -- whether to roll back when the deployment fails [default: `false`]
+
+A formal definition for the structure can be found in [the JSON schema](./deploy.json)
+
+For every profile of every node, arguments are merged with `` taking precedence over `` and `` taking precedence over top-level.
+
+Values can be overridden for all the profiles deployed by setting environment variables with the same names as the profile, for example `sshUser=foobar nix run github:serokell/deploy .` will connect to all nodes as `foobar@.hostname`.
diff --git a/interface/deploy.json b/interface/deploy.json
new file mode 100644
index 0000000..aaa6534
--- /dev/null
+++ b/interface/deploy.json
@@ -0,0 +1,103 @@
+{
+ "$schema": "http://json-schema.org/draft/2019-09/schema#",
+ "title": "Deploy",
+ "description": "Matches a correct deploy attribute of a flake",
+ "definitions": {
+ "generic_settings": {
+ "type": "object",
+ "properties": {
+ "sshUser": {
+ "type": "string"
+ },
+ "user": {
+ "type": "string"
+ },
+ "sshOpts": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "fastConnection": {
+ "type": "boolean"
+ },
+ "autoRollback": {
+ "type": "boolean"
+ }
+ }
+ },
+ "node_settings": {
+ "type": "object",
+ "properties": {
+ "hostname": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "hostname"
+ ]
+ },
+ "profile_settings": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "bootstrap": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "path"
+ ]
+ }
+ },
+ "type": "object",
+ "allOf": [
+ {
+ "$ref": "#/definitions/generic_settings"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "nodes": {
+ "type": "object",
+ "patternProperties": {
+ "[A-z][A-z0-9_-]*": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/generic_settings"
+ },
+ {
+ "$ref": "#/definitions/node_settings"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "profiles": {
+ "type": "object",
+ "patternProperties": {
+ "[A-z][A-z0-9_-]*": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/generic_settings"
+ },
+ {
+ "$ref": "#/definitions/profile_settings"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 0d80e42..219c3e5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,6 +10,7 @@ use tokio::process::Command;
use merge::Merge;
extern crate pretty_env_logger;
+
#[macro_use]
extern crate log;
@@ -177,12 +178,14 @@ async fn get_deployment_data(
let mut c = match supports_flakes {
true => Command::new("nix"),
- false => Command::new("nix-instanciate"),
+ false => Command::new("nix-instantiate"),
};
let mut build_command = match supports_flakes {
true => {
- c.arg("eval").arg("--json").arg(format!("{}#deploy", repo))
+ c.arg("eval")
+ .arg("--json")
+ .arg(format!("{}#deploy", repo))
}
false => {
c
@@ -190,7 +193,7 @@ async fn get_deployment_data(
.arg("--read-write-mode")
.arg("--json")
.arg("--eval")
- .arg("--E")
+ .arg("-E")
.arg(format!("let r = import {}/.; in if builtins.isFunction r then (r {{}}).deploy else r.deploy", repo))
}
};
--
cgit v1.3.1
From 58a934b997bb06f475bf707d0994f1fa37584cc1 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Mon, 5 Oct 2020 19:53:59 -0700
Subject: Clean up `simple` example
---
examples/simple/flake.lock | 4 ++--
examples/simple/flake.nix | 37 +++++++++----------------------------
2 files changed, 11 insertions(+), 30 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index 7791c84..1e2fab0 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -7,8 +7,8 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1601668691,
- "narHash": "sha256-1mWf71DPRNgTIUKJ4Dy+CjoyZo4JkPdrwjYJy2UzqZE=",
+ "lastModified": 1601952388,
+ "narHash": "sha256-g5t4JNUl4xmKfKmzo5yzligVNTBHOTgw+vkuebP4B/Q=",
"type": "git",
"url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
},
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
index d44b888..a8ad0f7 100644
--- a/examples/simple/flake.nix
+++ b/examples/simple/flake.nix
@@ -7,34 +7,15 @@
inputs.deploy-rs.url = "github:serokell/deploy-rs";
- outputs = { self, nixpkgs, deploy-rs }:
- let
- setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
- name = ("activatable-" + base.name);
- paths = [
- base
- (nixpkgs.legacyPackages.x86_64-linux.writeTextFile {
- name = base.name + "-activate-path";
- text = ''
- #!${nixpkgs.legacyPackages.x86_64-linux.runtimeShell}
- ${activate}
- '';
- executable = true;
- destination = "/activate";
- })
- ];
+ outputs = { self, nixpkgs, deploy-rs }: {
+ deploy.nodes.example = {
+ hostname = "localhost";
+ profiles.hello = {
+ user = "balsoft";
+ path = deploy-rs.lib.x86_64-linux.setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
};
- in
- {
-
- deploy.nodes.example = {
- hostname = "localhost";
- profiles.hello = {
- user = "balsoft";
- path = deploy-rs.lib.x86_64-linux.setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
- };
- };
-
- checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
};
+
+ checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
+ };
}
--
cgit v1.3.1
From aabcf6b77d4159100a49b143cbb8da4bad194f14 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Mon, 5 Oct 2020 20:10:41 -0700
Subject: Improve schema a bit, fix flake locks for examples
---
examples/simple/flake.lock | 10 ++++++----
examples/system/flake.lock | 10 ++++++----
interface/deploy.json | 44 +++++++++++++++++++++++---------------------
src/main.rs | 28 +++++++++++++++++++---------
src/utils/data.rs | 15 +++++++--------
5 files changed, 61 insertions(+), 46 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index 1e2fab0..8f4ca88 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -7,10 +7,12 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1601952388,
- "narHash": "sha256-g5t4JNUl4xmKfKmzo5yzligVNTBHOTgw+vkuebP4B/Q=",
- "type": "git",
- "url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
+ "lastModified": 1601952901,
+ "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
+ "owner": "serokell",
+ "repo": "deploy-rs",
+ "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
+ "type": "github"
},
"original": {
"owner": "serokell",
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index d3e489a..8f4ca88 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -7,10 +7,12 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1601668691,
- "narHash": "sha256-HvzPMsgSOQfCRoPtkwLRv09CkNjOsLHjcZtyHF+8Zbs=",
- "type": "git",
- "url": "file:///home/notgne2/Dev/Serokell/deploy-rs"
+ "lastModified": 1601952901,
+ "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
+ "owner": "serokell",
+ "repo": "deploy-rs",
+ "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
+ "type": "github"
},
"original": {
"owner": "serokell",
diff --git a/interface/deploy.json b/interface/deploy.json
index aaa6534..310e926 100644
--- a/interface/deploy.json
+++ b/interface/deploy.json
@@ -31,6 +31,29 @@
"properties": {
"hostname": {
"type": "string"
+ },
+ "profilesOrder": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "uniqueItems": true
+ },
+ "profiles": {
+ "type": "object",
+ "patternProperties": {
+ "[A-z][A-z0-9_-]*": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/generic_settings"
+ },
+ {
+ "$ref": "#/definitions/profile_settings"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
}
},
"required": [
@@ -70,27 +93,6 @@
},
{
"$ref": "#/definitions/node_settings"
- },
- {
- "type": "object",
- "properties": {
- "profiles": {
- "type": "object",
- "patternProperties": {
- "[A-z][A-z0-9_-]*": {
- "allOf": [
- {
- "$ref": "#/definitions/generic_settings"
- },
- {
- "$ref": "#/definitions/profile_settings"
- }
- ]
- }
- },
- "additionalProperties": false
- }
- }
}
]
}
diff --git a/src/main.rs b/src/main.rs
index 219c3e5..fb3fb66 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -65,17 +65,22 @@ async fn push_all_profiles(
) -> Result<(), Box> {
info!("Pushing all profiles for `{}`", node_name);
- let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect();
+ let mut profiles_list: Vec<&str> = node
+ .node_settings
+ .profiles_order
+ .iter()
+ .map(|x| x.as_ref())
+ .collect();
// Add any profiles which weren't in the provided order list
- for profile_name in node.profiles.keys() {
+ for profile_name in node.node_settings.profiles.keys() {
if !profiles_list.contains(&profile_name.as_str()) {
profiles_list.push(&profile_name);
}
}
for profile_name in profiles_list {
- let profile = match node.profiles.get(profile_name) {
+ let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};
@@ -117,17 +122,22 @@ async fn deploy_all_profiles(
) -> Result<(), Box> {
info!("Deploying all profiles for `{}`", node_name);
- let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect();
+ let mut profiles_list: Vec<&str> = node
+ .node_settings
+ .profiles_order
+ .iter()
+ .map(|x| x.as_ref())
+ .collect();
// Add any profiles which weren't in the provided order list
- for profile_name in node.profiles.keys() {
+ for profile_name in node.node_settings.profiles.keys() {
if !profiles_list.contains(&profile_name.as_str()) {
profiles_list.push(&profile_name);
}
}
for profile_name in profiles_list {
- let profile = match node.profiles.get(profile_name) {
+ let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};
@@ -203,8 +213,8 @@ async fn get_deployment_data(
}
let build_output = build_command
- .stdout(Stdio::null())
- .stderr(Stdio::null())
+ // .stdout(Stdio::null())
+ // .stderr(Stdio::null())
.output()
.await?;
@@ -233,7 +243,7 @@ async fn run_deploy(
Some(x) => x,
None => good_panic!("No node was found named `{}`", node_name),
};
- let profile = match node.profiles.get(profile_name) {
+ let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => good_panic!("No profile was found named `{}`", profile_name),
};
diff --git a/src/utils/data.rs b/src/utils/data.rs
index de6adfc..371c82d 100644
--- a/src/utils/data.rs
+++ b/src/utils/data.rs
@@ -29,6 +29,13 @@ pub struct GenericSettings {
#[derive(Deserialize, Debug, Clone)]
pub struct NodeSettings {
pub hostname: String,
+ pub profiles: HashMap,
+ #[serde(
+ skip_serializing_if = "Vec::is_empty",
+ default,
+ rename(deserialize = "profilesOrder")
+ )]
+ pub profiles_order: Vec,
}
#[derive(Deserialize, Debug, Clone)]
@@ -51,14 +58,6 @@ pub struct Node {
pub generic_settings: GenericSettings,
#[serde(flatten)]
pub node_settings: NodeSettings,
-
- pub profiles: HashMap,
- #[serde(
- skip_serializing_if = "Vec::is_empty",
- default,
- rename(deserialize = "profilesOrder")
- )]
- pub profiles_order: Vec,
}
#[derive(Deserialize, Debug, Clone)]
--
cgit v1.3.1
From 3a92593bf9c4ca07a2b09888e4a3f7dff6c9c510 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Tue, 6 Oct 2020 11:08:40 -0700
Subject: Add skip-push flag
---
examples/system/flake.lock | 6 ++---
src/main.rs | 61 +++++++++++++++++++++++++++-------------------
2 files changed, 39 insertions(+), 28 deletions(-)
(limited to 'examples')
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index 8f4ca88..b54c929 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -71,11 +71,11 @@
},
"nixpkgs_3": {
"locked": {
- "lastModified": 1592491430,
- "narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
+ "lastModified": 1601994071,
+ "narHash": "sha256-J1TNrQI3Gb5Yl9b4+O6eh1Zp1ha4YhI7ewsN1M/9x68=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "07299ff81e58e16b282fe602ce5e629854dfd544",
+ "rev": "6f90e1df4f27326c52b805cfd01fc79a49208e5c",
"type": "github"
},
"original": {
diff --git a/src/main.rs b/src/main.rs
index fb3fb66..04d7868 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -51,6 +51,9 @@ struct Opts {
/// Override hostname used for the node
#[clap(long)]
hostname: Option,
+ /// Skip pushing step (useful for local testing)
+ #[clap(short, long)]
+ skip_push: bool,
}
#[inline]
@@ -235,6 +238,7 @@ async fn run_deploy(
data: utils::data::Data,
supports_flakes: bool,
check_sigs: bool,
+ skip_push: bool,
cmd_overrides: utils::CmdOverrides,
) -> Result<(), Box> {
match (deploy_flake.node, deploy_flake.profile) {
@@ -259,14 +263,16 @@ async fn run_deploy(
let deploy_defs = deploy_data.defs();
- utils::push::push_profile(
- supports_flakes,
- check_sigs,
- deploy_flake.repo,
- &deploy_data,
- &deploy_defs,
- )
- .await?;
+ if !skip_push {
+ utils::push::push_profile(
+ supports_flakes,
+ check_sigs,
+ deploy_flake.repo,
+ &deploy_data,
+ &deploy_defs,
+ )
+ .await?;
+ }
utils::deploy::deploy_profile(&deploy_data, &deploy_defs).await?;
}
@@ -276,23 +282,7 @@ async fn run_deploy(
None => good_panic!("No node was found named `{}`", node_name),
};
- push_all_profiles(
- node,
- node_name,
- supports_flakes,
- deploy_flake.repo,
- &data.generic_settings,
- check_sigs,
- &cmd_overrides,
- )
- .await?;
-
- deploy_all_profiles(node, node_name, &data.generic_settings, &cmd_overrides).await?;
- }
- (None, None) => {
- info!("Deploying all profiles on all nodes");
-
- for (node_name, node) in &data.nodes {
+ if !skip_push {
push_all_profiles(
node,
node_name,
@@ -305,6 +295,26 @@ async fn run_deploy(
.await?;
}
+ deploy_all_profiles(node, node_name, &data.generic_settings, &cmd_overrides).await?;
+ }
+ (None, None) => {
+ info!("Deploying all profiles on all nodes");
+
+ if !skip_push {
+ for (node_name, node) in &data.nodes {
+ push_all_profiles(
+ node,
+ node_name,
+ supports_flakes,
+ deploy_flake.repo,
+ &data.generic_settings,
+ check_sigs,
+ &cmd_overrides,
+ )
+ .await?;
+ }
+ }
+
for (node_name, node) in &data.nodes {
deploy_all_profiles(node, node_name, &data.generic_settings, &cmd_overrides)
.await?;
@@ -363,6 +373,7 @@ async fn main() -> Result<(), Box> {
data,
supports_flakes,
opts.checksigs,
+ opts.skip_push,
cmd_overrides,
)
.await?;
--
cgit v1.3.1
From f2e5b9b39303ec66142caadad6aea74ee56a4c93 Mon Sep 17 00:00:00 2001
From: notgne2
Date: Sun, 11 Oct 2020 15:09:37 -0700
Subject: Update lock files
---
examples/simple/flake.lock | 53 +++++++++++++++++++++++++---------------------
examples/system/flake.lock | 53 +++++++++++++++++++++++++---------------------
flake.lock | 18 ++++++++--------
3 files changed, 67 insertions(+), 57 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index 8f4ca88..ff339a8 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -2,16 +2,17 @@
"nodes": {
"deploy-rs": {
"inputs": {
+ "flake-compat": "flake-compat",
"naersk": "naersk",
- "nixpkgs": "nixpkgs_2",
+ "nixpkgs": "nixpkgs",
"utils": "utils"
},
"locked": {
- "lastModified": 1601952901,
- "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
+ "lastModified": 1602454082,
+ "narHash": "sha256-nx6ULJCys3u+nLFHrt9+zux3fsfTloLTRd/FpJcL//Q=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
+ "rev": "e463c62922ad09f016e4f1dd1d6d0cabccb0ff79",
"type": "github"
},
"original": {
@@ -20,9 +21,27 @@
"type": "github"
}
},
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1600853454,
+ "narHash": "sha256-EgsgbcJNZ9AQLVhjhfiegGjLbO+StBY9hfKsCwc8Hw8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "94cf59784c73ecec461eaa291918eff0bfb538ac",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
"naersk": {
"inputs": {
- "nixpkgs": "nixpkgs"
+ "nixpkgs": [
+ "nixpkgs"
+ ]
},
"locked": {
"lastModified": 1597138680,
@@ -40,20 +59,6 @@
}
},
"nixpkgs": {
- "locked": {
- "lastModified": 1601091160,
- "narHash": "sha256-26UI9LGjRO8Sv253zJZkoapP260QkJPQ2+vRyC1i+kI=",
- "owner": "NixOS",
- "repo": "nixpkgs",
- "rev": "2768436826543af2b1540e4fe6b5afa15850e155",
- "type": "github"
- },
- "original": {
- "id": "nixpkgs",
- "type": "indirect"
- }
- },
- "nixpkgs_2": {
"locked": {
"lastModified": 1600387253,
"narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
@@ -69,13 +74,13 @@
"type": "github"
}
},
- "nixpkgs_3": {
+ "nixpkgs_2": {
"locked": {
- "lastModified": 1592491430,
- "narHash": "sha256-7WNpr16iUyjG4caad137nCqxXNTdct202jy05lslZXA=",
+ "lastModified": 1602453019,
+ "narHash": "sha256-bEzkPMG5JTFpd7xsl73/K/hZ9jBgiRKMdkpmwAG4lwI=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "07299ff81e58e16b282fe602ce5e629854dfd544",
+ "rev": "a6fec75d0472670448b9708e1619fef2c36af9d5",
"type": "github"
},
"original": {
@@ -86,7 +91,7 @@
"root": {
"inputs": {
"deploy-rs": "deploy-rs",
- "nixpkgs": "nixpkgs_3"
+ "nixpkgs": "nixpkgs_2"
}
},
"utils": {
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index b54c929..ff339a8 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -2,16 +2,17 @@
"nodes": {
"deploy-rs": {
"inputs": {
+ "flake-compat": "flake-compat",
"naersk": "naersk",
- "nixpkgs": "nixpkgs_2",
+ "nixpkgs": "nixpkgs",
"utils": "utils"
},
"locked": {
- "lastModified": 1601952901,
- "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=",
+ "lastModified": 1602454082,
+ "narHash": "sha256-nx6ULJCys3u+nLFHrt9+zux3fsfTloLTRd/FpJcL//Q=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156",
+ "rev": "e463c62922ad09f016e4f1dd1d6d0cabccb0ff79",
"type": "github"
},
"original": {
@@ -20,9 +21,27 @@
"type": "github"
}
},
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1600853454,
+ "narHash": "sha256-EgsgbcJNZ9AQLVhjhfiegGjLbO+StBY9hfKsCwc8Hw8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "94cf59784c73ecec461eaa291918eff0bfb538ac",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
"naersk": {
"inputs": {
- "nixpkgs": "nixpkgs"
+ "nixpkgs": [
+ "nixpkgs"
+ ]
},
"locked": {
"lastModified": 1597138680,
@@ -40,20 +59,6 @@
}
},
"nixpkgs": {
- "locked": {
- "lastModified": 1601091160,
- "narHash": "sha256-26UI9LGjRO8Sv253zJZkoapP260QkJPQ2+vRyC1i+kI=",
- "owner": "NixOS",
- "repo": "nixpkgs",
- "rev": "2768436826543af2b1540e4fe6b5afa15850e155",
- "type": "github"
- },
- "original": {
- "id": "nixpkgs",
- "type": "indirect"
- }
- },
- "nixpkgs_2": {
"locked": {
"lastModified": 1600387253,
"narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
@@ -69,13 +74,13 @@
"type": "github"
}
},
- "nixpkgs_3": {
+ "nixpkgs_2": {
"locked": {
- "lastModified": 1601994071,
- "narHash": "sha256-J1TNrQI3Gb5Yl9b4+O6eh1Zp1ha4YhI7ewsN1M/9x68=",
+ "lastModified": 1602453019,
+ "narHash": "sha256-bEzkPMG5JTFpd7xsl73/K/hZ9jBgiRKMdkpmwAG4lwI=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "6f90e1df4f27326c52b805cfd01fc79a49208e5c",
+ "rev": "a6fec75d0472670448b9708e1619fef2c36af9d5",
"type": "github"
},
"original": {
@@ -86,7 +91,7 @@
"root": {
"inputs": {
"deploy-rs": "deploy-rs",
- "nixpkgs": "nixpkgs_3"
+ "nixpkgs": "nixpkgs_2"
}
},
"utils": {
diff --git a/flake.lock b/flake.lock
index cbcd1bc..c9e4ff3 100644
--- a/flake.lock
+++ b/flake.lock
@@ -23,11 +23,11 @@
]
},
"locked": {
- "lastModified": 1597138680,
- "narHash": "sha256-3pDN/W17wjVDbrkgo60xQSb24+QAPQ7ulsUq5atNni0=",
+ "lastModified": 1602173141,
+ "narHash": "sha256-m6wU6lP0wf2OMw3KtJqn27ITtg29+ftciGHicLiVSGE=",
"owner": "nmattia",
"repo": "naersk",
- "rev": "529e910a3f423a8211f8739290014b754b2555b6",
+ "rev": "22b96210b2433228d42bce460f3befbdcfde7520",
"type": "github"
},
"original": {
@@ -39,11 +39,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1600387253,
- "narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
+ "lastModified": 1601961544,
+ "narHash": "sha256-uuh9CkDWkXlXse8IcergqoIM5JffqfQDKsl1uHB7XJI=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "72b9660dc18ba347f7cd41a9504fc181a6d87dc3",
+ "rev": "89281dd1dfed6839610f0ccad0c0e493606168fe",
"type": "github"
},
"original": {
@@ -63,11 +63,11 @@
},
"utils": {
"locked": {
- "lastModified": 1600209923,
- "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=",
+ "lastModified": 1601282935,
+ "narHash": "sha256-WQAFV6sGGQxrRs3a+/Yj9xUYvhTpukQJIcMbIi7LCJ4=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760",
+ "rev": "588973065fce51f4763287f0fda87a174d78bf48",
"type": "github"
},
"original": {
--
cgit v1.3.1
From 898bb2814b51fb76ef3d54164768512ed13016be Mon Sep 17 00:00:00 2001
From: notgne2
Date: Sun, 11 Oct 2020 15:19:34 -0700
Subject: Update lockfiles
---
examples/simple/flake.lock | 24 ++++++++++++------------
examples/system/flake.lock | 24 ++++++++++++------------
2 files changed, 24 insertions(+), 24 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index ff339a8..a6a3fa9 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -8,11 +8,11 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1602454082,
- "narHash": "sha256-nx6ULJCys3u+nLFHrt9+zux3fsfTloLTRd/FpJcL//Q=",
+ "lastModified": 1602454749,
+ "narHash": "sha256-wSPZEl6xyqewPrNQg9k6z3DLshn2Fwha8mDv8ECWMf8=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "e463c62922ad09f016e4f1dd1d6d0cabccb0ff79",
+ "rev": "e5bd558c5b6505621d3b5a27e9b39bf54f6788a1",
"type": "github"
},
"original": {
@@ -44,11 +44,11 @@
]
},
"locked": {
- "lastModified": 1597138680,
- "narHash": "sha256-3pDN/W17wjVDbrkgo60xQSb24+QAPQ7ulsUq5atNni0=",
+ "lastModified": 1602173141,
+ "narHash": "sha256-m6wU6lP0wf2OMw3KtJqn27ITtg29+ftciGHicLiVSGE=",
"owner": "nmattia",
"repo": "naersk",
- "rev": "529e910a3f423a8211f8739290014b754b2555b6",
+ "rev": "22b96210b2433228d42bce460f3befbdcfde7520",
"type": "github"
},
"original": {
@@ -60,11 +60,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1600387253,
- "narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
+ "lastModified": 1601961544,
+ "narHash": "sha256-uuh9CkDWkXlXse8IcergqoIM5JffqfQDKsl1uHB7XJI=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "72b9660dc18ba347f7cd41a9504fc181a6d87dc3",
+ "rev": "89281dd1dfed6839610f0ccad0c0e493606168fe",
"type": "github"
},
"original": {
@@ -96,11 +96,11 @@
},
"utils": {
"locked": {
- "lastModified": 1600209923,
- "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=",
+ "lastModified": 1601282935,
+ "narHash": "sha256-WQAFV6sGGQxrRs3a+/Yj9xUYvhTpukQJIcMbIi7LCJ4=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760",
+ "rev": "588973065fce51f4763287f0fda87a174d78bf48",
"type": "github"
},
"original": {
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index ff339a8..a6a3fa9 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -8,11 +8,11 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1602454082,
- "narHash": "sha256-nx6ULJCys3u+nLFHrt9+zux3fsfTloLTRd/FpJcL//Q=",
+ "lastModified": 1602454749,
+ "narHash": "sha256-wSPZEl6xyqewPrNQg9k6z3DLshn2Fwha8mDv8ECWMf8=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "e463c62922ad09f016e4f1dd1d6d0cabccb0ff79",
+ "rev": "e5bd558c5b6505621d3b5a27e9b39bf54f6788a1",
"type": "github"
},
"original": {
@@ -44,11 +44,11 @@
]
},
"locked": {
- "lastModified": 1597138680,
- "narHash": "sha256-3pDN/W17wjVDbrkgo60xQSb24+QAPQ7ulsUq5atNni0=",
+ "lastModified": 1602173141,
+ "narHash": "sha256-m6wU6lP0wf2OMw3KtJqn27ITtg29+ftciGHicLiVSGE=",
"owner": "nmattia",
"repo": "naersk",
- "rev": "529e910a3f423a8211f8739290014b754b2555b6",
+ "rev": "22b96210b2433228d42bce460f3befbdcfde7520",
"type": "github"
},
"original": {
@@ -60,11 +60,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1600387253,
- "narHash": "sha256-WtdpHuiunPF9QMlcXrWJkESuIjSSjP9WMOKvYQS/D7M=",
+ "lastModified": 1601961544,
+ "narHash": "sha256-uuh9CkDWkXlXse8IcergqoIM5JffqfQDKsl1uHB7XJI=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "72b9660dc18ba347f7cd41a9504fc181a6d87dc3",
+ "rev": "89281dd1dfed6839610f0ccad0c0e493606168fe",
"type": "github"
},
"original": {
@@ -96,11 +96,11 @@
},
"utils": {
"locked": {
- "lastModified": 1600209923,
- "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=",
+ "lastModified": 1601282935,
+ "narHash": "sha256-WQAFV6sGGQxrRs3a+/Yj9xUYvhTpukQJIcMbIi7LCJ4=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760",
+ "rev": "588973065fce51f4763287f0fda87a174d78bf48",
"type": "github"
},
"original": {
--
cgit v1.3.1
From 7ec0bc21cd3678e39270d7ea59bccaefa288abfa Mon Sep 17 00:00:00 2001
From: notgne2
Date: Mon, 26 Oct 2020 12:27:20 -0700
Subject: Update example flakes
---
examples/simple/flake.lock | 12 ++++++------
examples/simple/flake.nix | 2 +-
examples/system/flake.lock | 12 ++++++------
examples/system/flake.nix | 2 +-
4 files changed, 14 insertions(+), 14 deletions(-)
(limited to 'examples')
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock
index a6a3fa9..fc92f40 100644
--- a/examples/simple/flake.lock
+++ b/examples/simple/flake.lock
@@ -8,11 +8,11 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1602454749,
- "narHash": "sha256-wSPZEl6xyqewPrNQg9k6z3DLshn2Fwha8mDv8ECWMf8=",
+ "lastModified": 1603740297,
+ "narHash": "sha256-yeTrA8AaLzDFICApX725gQhKoHNI2TCqWAeOl9axVZE=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "e5bd558c5b6505621d3b5a27e9b39bf54f6788a1",
+ "rev": "426fb3c489dcbb4ccbf98a3ab6a7fe25e71b95ca",
"type": "github"
},
"original": {
@@ -76,11 +76,11 @@
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1602453019,
- "narHash": "sha256-bEzkPMG5JTFpd7xsl73/K/hZ9jBgiRKMdkpmwAG4lwI=",
+ "lastModified": 1603739127,
+ "narHash": "sha256-mdLESpo4jXrAynLp7ypRaqkx6IS1jx2l78f1tg9iiJU=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "a6fec75d0472670448b9708e1619fef2c36af9d5",
+ "rev": "d699505277b99e4698d90563c5eb1b62ba5ba0ea",
"type": "github"
},
"original": {
diff --git a/examples/simple/flake.nix b/examples/simple/flake.nix
index a8ad0f7..e5003c7 100644
--- a/examples/simple/flake.nix
+++ b/examples/simple/flake.nix
@@ -16,6 +16,6 @@
};
};
- checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
+ checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}
diff --git a/examples/system/flake.lock b/examples/system/flake.lock
index a6a3fa9..fc92f40 100644
--- a/examples/system/flake.lock
+++ b/examples/system/flake.lock
@@ -8,11 +8,11 @@
"utils": "utils"
},
"locked": {
- "lastModified": 1602454749,
- "narHash": "sha256-wSPZEl6xyqewPrNQg9k6z3DLshn2Fwha8mDv8ECWMf8=",
+ "lastModified": 1603740297,
+ "narHash": "sha256-yeTrA8AaLzDFICApX725gQhKoHNI2TCqWAeOl9axVZE=",
"owner": "serokell",
"repo": "deploy-rs",
- "rev": "e5bd558c5b6505621d3b5a27e9b39bf54f6788a1",
+ "rev": "426fb3c489dcbb4ccbf98a3ab6a7fe25e71b95ca",
"type": "github"
},
"original": {
@@ -76,11 +76,11 @@
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1602453019,
- "narHash": "sha256-bEzkPMG5JTFpd7xsl73/K/hZ9jBgiRKMdkpmwAG4lwI=",
+ "lastModified": 1603739127,
+ "narHash": "sha256-mdLESpo4jXrAynLp7ypRaqkx6IS1jx2l78f1tg9iiJU=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "a6fec75d0472670448b9708e1619fef2c36af9d5",
+ "rev": "d699505277b99e4698d90563c5eb1b62ba5ba0ea",
"type": "github"
},
"original": {
diff --git a/examples/system/flake.nix b/examples/system/flake.nix
index 32fefa1..021f9db 100644
--- a/examples/system/flake.nix
+++ b/examples/system/flake.nix
@@ -41,6 +41,6 @@
};
};
- checks = { "x86_64-linux" = { jsonSchema = deploy-rs.lib.x86_64-linux.checkSchema self.deploy; }; };
+ checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}
--
cgit v1.3.1