forked from fediversity/fediversity
Compare commits
2 commits
26d39b7b93
...
6eb27c06e2
| Author | SHA1 | Date | |
|---|---|---|---|
| 6eb27c06e2 | |||
| 3fd61aea5b |
3 changed files with 47 additions and 8 deletions
|
|
@ -1,5 +1,38 @@
|
||||||
/**
|
/**
|
||||||
Modular function type
|
Modular function type.
|
||||||
|
|
||||||
|
Compared to plain nix functions, adds input type-checks
|
||||||
|
at the cost of longer stack traces.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
my-function = lib.mkOption {
|
||||||
|
description = "My type-safe function invocation.";
|
||||||
|
type = lib.types.submodule PATH/TO/function.nix;
|
||||||
|
readOnly = true;
|
||||||
|
default = {
|
||||||
|
input-type = lib.types.int;
|
||||||
|
output-type = lib.types.int;
|
||||||
|
implementation = x: x + x;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
my-function.apply "1"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
A sample stack trace using this ends up like:
|
||||||
|
|
||||||
|
- `INVOKER.apply.<function body>``
|
||||||
|
- `function.nix`
|
||||||
|
- `INVOKER.wrapper.<function body>.output`
|
||||||
|
- `INVOKER.implementation.<function body>`
|
||||||
*/
|
*/
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
nixpkgs,
|
|
||||||
hostKeys ? { },
|
|
||||||
nixosConfiguration,
|
nixosConfiguration,
|
||||||
|
hostKeys ? { },
|
||||||
|
nixpkgs ? (import ../npins).nixpkgs,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -44,7 +44,7 @@ let
|
||||||
imports = [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ];
|
imports = [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ];
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
nixpkgs.hostPlatform = "x86_64-linux";
|
||||||
services.getty.autologinUser = lib.mkForce "root";
|
services.getty.autologinUser = lib.mkForce "root";
|
||||||
programs.bash.loginShellInit = nixpkgs.lib.getExe bootstrap;
|
programs.bash.loginShellInit = lib.getExe bootstrap;
|
||||||
|
|
||||||
isoImage = {
|
isoImage = {
|
||||||
compressImage = false;
|
compressImage = false;
|
||||||
|
|
@ -55,4 +55,10 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
(nixpkgs.lib.nixosSystem { modules = [ installer ]; }).config.system.build.isoImage
|
(import "${nixpkgs}/nixos/lib/eval-config.nix" {
|
||||||
|
modules = [ installer ];
|
||||||
|
# Allow system to be set modularly in nixpkgs.system.
|
||||||
|
# We set it to null, to remove the "legacy" entrypoint's
|
||||||
|
# non-hermetic default.
|
||||||
|
system = null;
|
||||||
|
}).config.system.build.isoImage
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,9 @@ build_iso () {
|
||||||
nix build \
|
nix build \
|
||||||
--impure --expr "
|
--impure --expr "
|
||||||
let flake = builtins.getFlake (builtins.toString ./.); in
|
let flake = builtins.getFlake (builtins.toString ./.); in
|
||||||
import ./makeInstallerIso.nix {
|
import ./infra/makeInstallerIso.nix {
|
||||||
nixosConfiguration = flake.nixosConfigurations.$vm_name;
|
nixosConfiguration = flake.nixosConfigurations.$vm_name;
|
||||||
nixpkgs = flake.inputs.nixpkgs;
|
# FIXME pass nixpkgs from npins
|
||||||
$nix_host_keys
|
$nix_host_keys
|
||||||
}
|
}
|
||||||
" \
|
" \
|
||||||
|
|
@ -239,7 +239,7 @@ Check the Nix logs and fix things. Possibly there just is no NixOS configuration
|
||||||
"$vm_name"
|
"$vm_name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf "$tmpdir/installer-$vm_name/iso/installer.iso" "$tmpdir/installer-$vm_name.iso"
|
ln -sf "$(ls "$tmpdir/installer-$vm_name"/iso/nixos-*.iso)" "$tmpdir/installer-$vm_name.iso"
|
||||||
|
|
||||||
printf 'done building ISO for VM %s.\n' "$vm_name"
|
printf 'done building ISO for VM %s.\n' "$vm_name"
|
||||||
release_lock build
|
release_lock build
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue