Skip to content

Update docs and examples #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ In the above configuration, `deploy-rs` is built from the flake, not from nixpkg
deployPkgs = import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay # or deploy-rs.overlays.default
deploy-rs.overlays.default
(self: super: { deploy-rs = { inherit (pkgs) deploy-rs; lib = super.deploy-rs.lib; }; })
];
};
Expand Down
67 changes: 39 additions & 28 deletions examples/darwin/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,47 @@
inputs.deploy-rs.url = "github:serokell/deploy-rs";
inputs.darwin.url = "github:LnL7/nix-darwin";

outputs = { self, nixpkgs, deploy-rs, darwin }: {
darwinConfigurations.example = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
({lib, config, pkgs, ...}: {
services.nix-daemon.enable = true;
nix = {
settings = {
trusted-users = [ "rvem" ];
};
extraOptions = ''
experimental-features = flakes nix-command
'';
outputs =
{
self,
deploy-rs,
darwin,
}:
{
darwinConfigurations.example = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
(
{
...
}:
{
services.nix-daemon.enable = true;
nix = {
settings = {
trusted-users = [ "rvem" ];
};
extraOptions = ''
experimental-features = flakes nix-command
'';
};
# nix commands are added to PATH in the zsh config
programs.zsh.enable = true;
}
)
];
};
deploy = {
# remoteBuild = true; # Uncomment in case the system you're deploying from is not darwin
nodes.example = {
hostname = "localhost";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-darwin.activate.darwin self.darwinConfigurations.example;
};
# nix commands are added to PATH in the zsh config
programs.zsh.enable = true;
})
];
};
deploy = {
# remoteBuild = true; # Uncomment in case the system you're deploying from is not darwin
nodes.example = {
hostname = "localhost";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-darwin.activate.darwin self.darwinConfigurations.example;
};
};
};

checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}
70 changes: 33 additions & 37 deletions examples/simple/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions examples/simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@

inputs.deploy-rs.url = "github:serokell/deploy-rs";

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";
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";
};
};
};

checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}
13 changes: 8 additions & 5 deletions examples/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ SPDX-License-Identifier: MPL-2.0
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-rs`
3. ???
4. PROFIT!!!

- `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-rs -- .#example.system` (password for `admin`: `123`)
3. `nix run github:serokell/deploy-rs -- .#example.hello` (password for `hello`: `abc`)
4. ???
5. PROFIT!!!
54 changes: 34 additions & 20 deletions examples/system/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,46 @@
# SPDX-License-Identifier: MPL-2.0

{
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" ];
extraGroups = [
"wheel"
"sudo"
];
password = "123";
};

services.openssh = { enable = true; };
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="
security.sudo.extraRules = [
{
groups = [ "wheel" ];
commands = [
{
command = "ALL";
options = [ "NOPASSWD" ];
}
];
}
];

nix.settings = {
# allow users in the weel group to upload unsigned nars
trusted-users = [ "@wheel" ];
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
};

# these settings are needed in order for there to be a `/boot`
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};

# settings for the vm
virtualisation = {
useBootLoader = true;
writableStore = true;
useEFIBoot = true;
};
}
3 changes: 2 additions & 1 deletion examples/system/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

users.users.hello = {
isNormalUser = true;
password = "";
password = "abc";
extraGroups = [ "wheel" ];
uid = 1010;
};
}
Loading