diff options
| author | notgne2 | 2020-09-28 16:17:31 -0700 | 
|---|---|---|
| committer | notgne2 | 2020-09-28 16:17:31 -0700 | 
| commit | edaed825650eea32878441d3b8c7eb40e8877882 (patch) | |
| tree | ba0e313a5cd2711de11e9fe9d973073171519ee5 /examples/system/flake.nix | |
| parent | 239d0f8999b47e9e76589ee1fa2d9f3459c47335 (diff) | |
Add examples
Diffstat (limited to 'examples/system/flake.nix')
| -rw-r--r-- | examples/system/flake.nix | 46 | 
1 files changed, 46 insertions, 0 deletions
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; +  }; +}  | 
