mirror of
https://github.com/TECHNOFAB11/disko.git
synced 2025-12-13 00:20:05 +01:00
commit
91efad5326
8 changed files with 85 additions and 25 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
result
|
||||||
|
|
@ -36,16 +36,16 @@ This is how your iso configuation may look like
|
||||||
|
|
||||||
/etc/nixos/configuration.nix
|
/etc/nixos/configuration.nix
|
||||||
```nix
|
```nix
|
||||||
{ pkgs, ... }:
|
{ pkgs, modulesPath, ... }:
|
||||||
let
|
let
|
||||||
disko = (builtins.fetchGit {
|
disko = builtins.fetchGit {
|
||||||
url = https://cgit.lassul.us/disko/;
|
url = https://cgit.lassul.us/disko/;
|
||||||
rev = "88f56a0b644dd7bfa8438409bea5377adef6aef4";
|
rev = "88f56a0b644dd7bfa8438409bea5377adef6aef4";
|
||||||
}) + "/lib";
|
};
|
||||||
cfg = builtins.fromJSON ./tsp-disk.json;
|
cfg = builtins.fromJSON ./tsp-disk.json;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
|
(modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
|
||||||
];
|
];
|
||||||
environment.systemPackages = with pkgs;[
|
environment.systemPackages = with pkgs;[
|
||||||
(pkgs.writeScriptBin "tsp-create" (disko.create cfg))
|
(pkgs.writeScriptBin "tsp-create" (disko.create cfg))
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
{
|
{ lib ? (import <nixpkgs> {}).lib }: {
|
||||||
inherit (import ./lib) config create mount;
|
inherit (import ./lib {
|
||||||
|
inherit lib;
|
||||||
|
}) config create mount;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# usage: nix-instantiate --eval --json --strict example | jq -r .
|
# usage: nix-instantiate --eval --json --strict example | jq -r .
|
||||||
|
|
||||||
with import ../lib;
|
let
|
||||||
|
# TODO: get rid of NIX_PATH dependency here
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
with import ../lib { inherit (pkgs) lib;};
|
||||||
|
|
||||||
{
|
{
|
||||||
config = config (import ./config.nix);
|
config = config (import ./config.nix);
|
||||||
|
|
|
||||||
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1660646295,
|
||||||
|
"narHash": "sha256-V4G+egGRc3elXPTr7QLJ7r7yrYed0areIKDiIAlMLC8=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "762b003329510ea855b4097a37511eb19c7077f0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
19
flake.nix
Normal file
19
flake.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
description = "Description for the project";
|
||||||
|
|
||||||
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, ... }: {
|
||||||
|
lib = import ./. {
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
};
|
||||||
|
checks.x86_64-linux = let
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
in {
|
||||||
|
# Run tests: nix flake check -L
|
||||||
|
nixos-test = pkgs.callPackage ./tests/test.nix {
|
||||||
|
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
with import <nixpkgs/lib>;
|
{ lib }:
|
||||||
|
with lib;
|
||||||
with builtins;
|
with builtins;
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
@ -130,5 +131,4 @@ let {
|
||||||
|
|
||||||
mount.table = q: x:
|
mount.table = q: x:
|
||||||
foldl' recursiveUpdate {} (imap (index: mount-f (q // { inherit index; })) x.partitions);
|
foldl' recursiveUpdate {} (imap (index: mount-f (q // { inherit index; })) x.partitions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, ... }: let
|
{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
|
||||||
|
, pkgs ? (import <nixpkgs> {})
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
makeTest' = args:
|
||||||
|
makeTest args {
|
||||||
|
inherit pkgs;
|
||||||
|
inherit (pkgs) system;
|
||||||
|
};
|
||||||
disko-config = {
|
disko-config = {
|
||||||
type = "devices";
|
type = "devices";
|
||||||
content = {
|
content = {
|
||||||
|
|
@ -78,28 +85,28 @@ import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, ... }: let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
in makeTest' {
|
||||||
in {
|
|
||||||
name = "disko";
|
name = "disko";
|
||||||
|
|
||||||
nodes.machine =
|
nodes.machine =
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
<nixpkgs/nixos/modules/profiles/installation-device.nix>
|
(modulesPath + "/profiles/installation-device.nix")
|
||||||
<nixpkgs/nixos/modules/profiles/base.nix>
|
(modulesPath + "/profiles/base.nix")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# speed-up eval
|
||||||
|
documentation.enable = false;
|
||||||
|
|
||||||
virtualisation.emptyDiskImages = [ 512 ];
|
virtualisation.emptyDiskImages = [ 512 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript = ''
|
||||||
''
|
machine.succeed("echo 'secret' > /tmp/secret.key");
|
||||||
machine.succeed("echo 'secret' > /tmp/secret.key");
|
machine.succeed("${pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config)}");
|
||||||
machine.succeed("${pkgs.writeScript "create" ((import ../lib).create disko-config)}");
|
machine.succeed("${pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config)}");
|
||||||
machine.succeed("${pkgs.writeScript "mount" ((import ../lib).mount disko-config)}");
|
machine.succeed("test -b /dev/mapper/pool-raw");
|
||||||
machine.succeed("test -b /dev/mapper/pool-raw");
|
'';
|
||||||
'';
|
}
|
||||||
|
|
||||||
})
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue