mirror of
https://github.com/nix-community/disko.git
synced 2026-01-15 10:48:38 +01:00
Fixes #745 This adds a script to create a release. Running it will create two commits that would appear like this in `git log --oneline`: 67b5fff (master) release: reset released flag 0b808f3 (tag: v1.8.1) release: v1.8.1 100d2f3 docs: last change before release It also re-creates the `version.nix` file, which is used by the flake to determine the final version the disko CLI will print. If `disko --version` is run from exactly the commit tagged `v1.8.1`, it will print `1.8.1`. If it is run from any commit past that (like master), it will print `1.8.1-67b5fff`, and if it is run from a local folder with uncommitted changes, it will print `1.8.1-67b5fff-dirty`.
61 lines
2.5 KiB
Nix
61 lines
2.5 KiB
Nix
{ pkgs ? import <nixpkgs> { }, self, diskoVersion }:
|
|
let
|
|
disko = pkgs.callPackage ../../package.nix { inherit diskoVersion; };
|
|
|
|
dependencies = [
|
|
self.nixosConfigurations.testmachine.pkgs.stdenv.drvPath
|
|
(self.nixosConfigurations.testmachine.pkgs.closureInfo { rootPaths = [ ]; }).drvPath
|
|
self.nixosConfigurations.testmachine.config.system.build.toplevel
|
|
self.nixosConfigurations.testmachine.config.system.build.diskoScript
|
|
] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
|
|
|
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
|
in
|
|
pkgs.nixosTest {
|
|
name = "disko-test";
|
|
nodes.machine = {
|
|
virtualisation.emptyDiskImages = [ 4096 ];
|
|
virtualisation.memorySize = 3000;
|
|
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
|
};
|
|
|
|
testScript = ''
|
|
def create_test_machine(
|
|
oldmachine=None, **kwargs
|
|
): # taken from <nixpkgs/nixos/tests/installer.nix>
|
|
start_command = [
|
|
"${pkgs.qemu_test}/bin/qemu-kvm",
|
|
"-cpu",
|
|
"max",
|
|
"-m",
|
|
"1024",
|
|
"-virtfs",
|
|
"local,path=/nix/store,security_model=none,mount_tag=nix-store",
|
|
"-drive",
|
|
f"file={oldmachine.state_dir}/empty0.qcow2,id=drive1,if=none,index=1,werror=report",
|
|
"-device",
|
|
"virtio-blk-pci,drive=drive1",
|
|
]
|
|
machine = create_machine(start_command=" ".join(start_command), **kwargs)
|
|
driver.machines.append(machine)
|
|
return machine
|
|
machine.succeed("lsblk >&2")
|
|
|
|
print(machine.succeed("tty"))
|
|
machine.succeed("umask 066; echo > /tmp/age.key")
|
|
permission = machine.succeed("stat -c %a /tmp/age.key").strip()
|
|
assert permission == "600", f"expected permission 600 on /tmp/age.key, got {permission}"
|
|
|
|
machine.succeed("${disko}/bin/disko-install --disk main /dev/vdb --extra-files /tmp/age.key /var/lib/secrets/age.key --flake ${../..}#testmachine")
|
|
# test idempotency
|
|
machine.succeed("${disko}/bin/disko-install --mode mount --disk main /dev/vdb --flake ${../..}#testmachine")
|
|
machine.shutdown()
|
|
|
|
new_machine = create_test_machine(oldmachine=machine, name="after_install")
|
|
new_machine.start()
|
|
name = new_machine.succeed("hostname").strip()
|
|
assert name == "disko-machine", f"expected hostname 'disko-machine', got {name}"
|
|
permission = new_machine.succeed("stat -c %a /var/lib/secrets/age.key").strip()
|
|
assert permission == "600", f"expected permission 600 on /var/lib/secrets/age.key, got {permission}"
|
|
'';
|
|
}
|