diff --git a/flake.lock b/flake.lock index 9cd53c6f..7ca4b12a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,16 +16,83 @@ "type": "github" } }, + "advisory-db_2": { + "flake": false, + "locked": { + "lastModified": 1723840407, + "narHash": "sha256-AZI593yLh4lcKJdAnnjyLMKUm5PMDpFy1APIYFURLyI=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "201638b35a3e85b7794e84cc73f876d7a2b7ad51", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, "agenix": { "inputs": { "darwin": "darwin", "home-manager": "home-manager", "nixpkgs": [ + "cctl-rs", + "cctl-2", "csprpkgs", "nixpkgs" ], "systems": "systems_2" }, + "locked": { + "lastModified": 1712079060, + "narHash": "sha256-/JdiT9t+zzjChc5qQiF+jhrVhRt8figYH29rZO7pFe4=", + "owner": "ryantm", + "repo": "agenix", + "rev": "1381a759b205dff7a6818733118d02253340fd5e", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "agenix_2": { + "inputs": { + "darwin": "darwin_2", + "home-manager": "home-manager_2", + "nixpkgs": [ + "cctl-rs", + "csprpkgs", + "nixpkgs" + ], + "systems": "systems_4" + }, + "locked": { + "lastModified": 1722339003, + "narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=", + "owner": "ryantm", + "repo": "agenix", + "rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "agenix_3": { + "inputs": { + "darwin": "darwin_3", + "home-manager": "home-manager_3", + "nixpkgs": [ + "csprpkgs", + "nixpkgs" + ], + "systems": "systems_5" + }, "locked": { "lastModified": 1722339003, "narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=", @@ -69,7 +136,86 @@ "type": "github" } }, + "cctl-2": { + "inputs": { + "csprpkgs": "csprpkgs_2", + "nixpkgs": [ + "cctl-rs", + "cctl-2", + "csprpkgs", + "nixpkgs" + ], + "rust-overlay": [ + "cctl-rs", + "cctl-2", + "csprpkgs", + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1723558192, + "narHash": "sha256-Y9Ct935VyCdOIYfl+QDNAE2bMCnDJOu2HCwZnm/mbsI=", + "owner": "casper-network", + "repo": "cctl", + "rev": "2da83ec5e50c64bd8d7f9c6c986c1da375465678", + "type": "github" + }, + "original": { + "owner": "casper-network", + "repo": "cctl", + "type": "github" + } + }, + "cctl-rs": { + "inputs": { + "advisory-db": "advisory-db_2", + "cctl": [ + "cctl" + ], + "cctl-2": "cctl-2", + "crane": "crane", + "csprpkgs": "csprpkgs_3", + "fenix": "fenix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_4", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1724679624, + "narHash": "sha256-bh/iVO+LEl88DxZIWCFlQ3fu6uMUBN3Ou5+fwCgJiDk=", + "owner": "cspr-rad", + "repo": "cctl-rs", + "rev": "da4400558ead366af9c075b5c02d16f30ddadcea", + "type": "github" + }, + "original": { + "owner": "cspr-rad", + "repo": "cctl-rs", + "type": "github" + } + }, "crane": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724006180, + "narHash": "sha256-PVxPj0Ga2fMYMtcT9ARCthF+4U71YkOT7ZjgD/vf1Aw=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7ce92819802bc583b7e82ebc08013a530f22209f", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -114,6 +260,46 @@ "nixpkgs": "nixpkgs_2", "rust-overlay": "rust-overlay_2" }, + "locked": { + "lastModified": 1722410860, + "narHash": "sha256-aL5bf+/X3YR+uqVgD6t1tT23Xw47XJDfE2tXQ2uF6uw=", + "owner": "cspr-rad", + "repo": "csprpkgs", + "rev": "ba58f48daf43bfc84467261969b2388ab779b2de", + "type": "github" + }, + "original": { + "owner": "cspr-rad", + "repo": "csprpkgs", + "type": "github" + } + }, + "csprpkgs_3": { + "inputs": { + "agenix": "agenix_2", + "nixpkgs": "nixpkgs_3", + "rust-overlay": "rust-overlay_3" + }, + "locked": { + "lastModified": 1723826679, + "narHash": "sha256-ZL9tppGgOsJi0Z49Lc77mfy3GakX/QbI1CIIKGt4gjs=", + "owner": "cspr-rad", + "repo": "csprpkgs", + "rev": "2e3b082f9bf3b0239f12dec7246b4d19534b811e", + "type": "github" + }, + "original": { + "owner": "cspr-rad", + "repo": "csprpkgs", + "type": "github" + } + }, + "csprpkgs_4": { + "inputs": { + "agenix": "agenix_3", + "nixpkgs": "nixpkgs_5", + "rust-overlay": "rust-overlay_4" + }, "locked": { "lastModified": 1722882341, "narHash": "sha256-WhbUtqJLRhE58YGMhclqBzvrIQ+6j4QIzLsiPKipgCw=", @@ -129,6 +315,55 @@ } }, "darwin": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "cctl-2", + "csprpkgs", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700795494, + "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "darwin_2": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "csprpkgs", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700795494, + "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "darwin_3": { "inputs": { "nixpkgs": [ "csprpkgs", @@ -154,10 +389,32 @@ "fenix": { "inputs": { "nixpkgs": [ + "cctl-rs", "nixpkgs" ], "rust-analyzer-src": "rust-analyzer-src" }, + "locked": { + "lastModified": 1724049063, + "narHash": "sha256-aTnh9Ar40OaT2MTULeJMR9EIrylKeKUYWP61QEZBu0Q=", + "owner": "nix-community", + "repo": "fenix", + "rev": "94c18bf5acb3966b07cc863bd00f4f959c0c5ec4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src_2" + }, "locked": { "lastModified": 1715754333, "narHash": "sha256-u3B+RvDD/kPxMS0Dkm+x+BlzfCqghT3kdev+1UYKvis=", @@ -176,6 +433,24 @@ "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, + "locked": { + "lastModified": 1722555600, + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, "locked": { "lastModified": 1709336216, "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", @@ -208,7 +483,72 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "cctl-2", + "csprpkgs", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703113217, + "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "csprpkgs", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703113217, + "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_3": { "inputs": { "nixpkgs": [ "csprpkgs", @@ -247,6 +587,18 @@ } }, "nixpkgs-lib": { + "locked": { + "lastModified": 1722555339, + "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" + } + }, + "nixpkgs-lib_2": { "locked": { "dir": "lib", "lastModified": 1709237383, @@ -265,6 +617,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1712192574, + "narHash": "sha256-LbbVOliJKTF4Zl2b9salumvdMXuQBr2kuKP5+ZwbYq4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f480f9d09e4b4cf87ee6151eba068197125714de", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1722730825, "narHash": "sha256-X6U+w8qFBuGPCYrZzc9mpN34aRjQ8604MonpBUkj908=", @@ -280,7 +648,39 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { + "locked": { + "lastModified": 1724015816, + "narHash": "sha256-hVESnM7Eiz93+4DeiE0a1TwMeaeph1ytRJ5QtqxYRWg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9aa35efbea27d320d0cdc5f922f0890812affb60", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1722730825, + "narHash": "sha256-X6U+w8qFBuGPCYrZzc9mpN34aRjQ8604MonpBUkj908=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f3834de3782b82bfc666abf664f946d0e7d1f116", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { "locked": { "lastModified": 1721782431, "narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=", @@ -300,15 +700,33 @@ "inputs": { "advisory-db": "advisory-db", "cctl": "cctl", - "crane": "crane", - "csprpkgs": "csprpkgs_2", - "fenix": "fenix", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_3", - "treefmt-nix": "treefmt-nix" + "cctl-rs": "cctl-rs", + "crane": "crane_2", + "csprpkgs": "csprpkgs_4", + "fenix": "fenix_2", + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_6", + "treefmt-nix": "treefmt-nix_2" } }, "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1723915239, + "narHash": "sha256-x/RXN/ougJ1IEoBKrY0UijB530OfOfICK4KPa3Kj9Bk=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "fa003262474185fd62168379500fe906b331824b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_2": { "flake": false, "locked": { "lastModified": 1715714902, @@ -349,6 +767,52 @@ } }, "rust-overlay_2": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "cctl-rs", + "cctl-2", + "csprpkgs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706753617, + "narHash": "sha256-ZKqTFzhFwSWFEpQTJ0uXnfJBs5Y/po9/8TK4bzssdbs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "58be43ae223034217ea1bd58c73210644031b687", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "csprpkgs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722824458, + "narHash": "sha256-2k3/geD5Yh8JT1nrGaRycje5kB0DkvQA/OUZoel1bIU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "a8a937c304e62a5098c6276c9cdf65c19a43b1a5", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_4": { "inputs": { "nixpkgs": [ "csprpkgs", @@ -399,7 +863,73 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "cctl-rs", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723808491, + "narHash": "sha256-rhis3qNuGmJmYC/okT7Dkc4M8CeUuRCSvW6kC2f3hBc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1d07739554fdc4f8481068f1b11d6ab4c1a4167a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { "inputs": { "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index 6b3ad874..4e06dd15 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,8 @@ advisory-db.flake = false; cctl.url = "github:casper-network/cctl/947c34b991e37476db82ccfa2bd7c0312c1a91d7"; csprpkgs.url = "github:cspr-rad/csprpkgs"; + cctl-rs.url = "github:cspr-rad/cctl-rs"; + cctl-rs.inputs.cctl.follows = "cctl"; }; outputs = inputs@{ flake-parts, treefmt-nix, ... }: diff --git a/nixos/default.nix b/nixos/default.nix index 0a153cfc..f7c826af 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -49,7 +49,7 @@ in { inherit mkKairosHostConfig; inherit (self.packages.${pkgs.system}) kairos kairos-contracts casper-client-rs casper-node-config casper-chainspec; - cctlModule = self.nixosModules.cctl; + cctlModule = inputs.cctl-rs.nixosModules.cctl; }; }; nixosModules = { @@ -65,12 +65,6 @@ in imports = [ ./modules/kairos-prover.nix ]; services.kairos-prover.package = self.packages.${pkgs.system}.kairos-prover; }; - cctl = - { pkgs, lib, ... }: - { - imports = [ ./modules/cctl.nix ]; - services.cctl.package = self.packages.${pkgs.system}.cctld; - }; }; }; } diff --git a/nixos/modules/cctl.nix b/nixos/modules/cctl.nix deleted file mode 100644 index bef9edec..00000000 --- a/nixos/modules/cctl.nix +++ /dev/null @@ -1,158 +0,0 @@ -{ lib, config, ... }: -let - inherit (lib) - types - mkOption - mkIf - mkMerge - mkEnableOption - escapeShellArgs - optionals - ; - cfg = config.services.cctl; -in -{ - options.services.cctl = { - - enable = mkEnableOption "cctl"; - - package = mkOption { - type = types.package; - }; - - port = mkOption { - type = types.port; - default = 11101; - example = 60000; - description = '' - Port to listen on. - TODO make port configurable in cctl - ''; - }; - - workingDirectory = mkOption { - type = types.path; - default = "/var/lib/cctl"; - description = '' - The working directory path where cctl will put its assets and resources. - ''; - }; - - chainspec = mkOption { - type = types.nullOr types.path; - default = null; - description = '' - The path to a chainspec.toml. - ''; - }; - - config = mkOption { - type = types.nullOr types.path; - default = null; - description = '' - The path to a casper node config.toml. - ''; - }; - - logLevel = mkOption { - type = types.str; - default = "info"; - description = '' - The log-level that should be used. - ''; - }; - - contract = mkOption { - type = types.nullOr (types.attrsOf types.path); - default = null; - example = { "contract hash name" = "/path/to/contract.wasm"; }; - description = '' - The wasm compiled contract that should be deployed once the network is up and ready. - The name of the attribute should correspond to the contracts hash name when calling - https://docs.rs/casper-contract/latest/casper_contract/contract_api/storage/fn.new_locked_contract.html - ''; - }; - - }; - - config = mkIf cfg.enable { - - systemd.services.cctl = - let - args = escapeShellArgs ([ - "--working-dir" - cfg.workingDirectory - ] - ++ optionals (!builtins.isNull cfg.contract) ([ - "--deploy-contract" - ] ++ (lib.mapAttrsToList (hash_name: contract_path: "${hash_name}:${contract_path}") cfg.contract)) - ++ optionals (!builtins.isNull cfg.chainspec) [ - "--chainspec-path" - cfg.chainspec - ] - ++ optionals (!builtins.isNull cfg.config) [ - "--config-path" - cfg.config - ]); - in - { - description = "cctl"; - documentation = [ "" ]; - wantedBy = [ "multi-user.target" ]; - after = [ "network-online.target" ]; - requires = [ "network-online.target" ]; - environment = { - RUST_LOG = cfg.logLevel; - }; - serviceConfig = - mkMerge [ - { - ExecStart = "${lib.getExe cfg.package} ${args}"; - Type = "notify"; - Restart = "no"; - User = "cctl"; - Group = "cctl"; - TimeoutStartSec = 1000; - StateDirectory = builtins.baseNameOf cfg.workingDirectory; - WorkingDirectory = cfg.workingDirectory; - ReadWritePaths = [ - cfg.workingDirectory - ]; - } - ]; - }; - - users.users.cctl = { - name = "cctl"; - group = "cctl"; - isSystemUser = true; - }; - users.groups.cctl = { }; - - # Allows nginx to have read access to the working directory of cctl - users.users.${config.services.nginx.user}.extraGroups = [ "cctl" ]; - - # Since cctl is usually ran on the same machine as the application that is subject to be tested, - # we need to serve the generated users directory to make it available for client machines - # when testing - services.nginx = { - enable = true; - virtualHosts."${config.networking.hostName}".locations = { - "/cctl/users/" = { - alias = "${cfg.workingDirectory}/assets/users/"; - extraConfig = '' - autoindex on; - add_header Content-Type 'text/plain charset=UTF-8'; - ''; - }; - "/cctl/contracts/" = { - alias = "${cfg.workingDirectory}/contracts/"; - extraConfig = '' - autoindex on; - add_header Content-Type 'text/plain charset=UTF-8'; - ''; - }; - }; - }; - }; -}