mirror of
https://github.com/nix-community/disko.git
synced 2024-11-04 05:44:29 +03:00
Merge #146
146: style: Add config for style normalisation and re-apply r=Lassulus a=cscutcher Co-authored-by: Chris Scutcher <chris@scutcher.uk>
This commit is contained in:
commit
9afae0ba36
@ -16,7 +16,7 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit types;
|
||||
types = types;
|
||||
create = cfg: types.diskoLib.create (eval cfg).config.devices;
|
||||
createScript = cfg: pkgs: pkgs.writeScript "disko-create" ''
|
||||
#!/usr/bin/env bash
|
||||
|
2
doc.nix
2
doc.nix
@ -19,7 +19,7 @@ let
|
||||
];
|
||||
};
|
||||
options = nixosOptionsDoc {
|
||||
inherit (eval) options;
|
||||
options = eval.options;
|
||||
};
|
||||
md = (runCommand "disko-options.md" { } ''
|
||||
cat >$out <<EOF
|
||||
|
@ -13,7 +13,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
type = "partition";
|
||||
@ -53,7 +53,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
type = "partition";
|
||||
|
@ -35,12 +35,12 @@
|
||||
};
|
||||
# Mountpoints inferred from subvolume name
|
||||
"/home" = {
|
||||
mountOptions = ["compress=zstd"];
|
||||
mountOptions = [ "compress=zstd" ];
|
||||
};
|
||||
"/nix" = {
|
||||
mountOptions = ["compress=zstd" "noatime"];
|
||||
mountOptions = [ "compress=zstd" "noatime" ];
|
||||
};
|
||||
"/test" = {};
|
||||
"/test" = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
part-type = "primary";
|
||||
start = "1024MiB";
|
||||
end = "100%";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "crypted";
|
||||
|
@ -14,7 +14,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
name = "root";
|
||||
|
@ -13,7 +13,7 @@
|
||||
type = "partition";
|
||||
start = "0";
|
||||
end = "1M";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
type = "partition";
|
||||
|
@ -13,7 +13,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
type = "partition";
|
||||
@ -41,7 +41,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
type = "partition";
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{ pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
# We just import from the repository for testing here:
|
||||
disko = import ../../. {
|
||||
inherit lib;
|
||||
@ -41,7 +41,8 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(disko.config cfg)
|
||||
];
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Example to create a bios compatible gpt partition
|
||||
{ disks ? [ "/dev/vdb" ], lib, ... }: {
|
||||
disk = lib.genAttrs [ (lib.head disks) ] (device: {
|
||||
inherit device;
|
||||
device = device;
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "table";
|
||||
@ -13,7 +13,7 @@
|
||||
start = "0";
|
||||
end = "1M";
|
||||
part-type = "primary";
|
||||
flags = ["bios_grub"];
|
||||
flags = [ "bios_grub" ];
|
||||
}
|
||||
{
|
||||
name = "root";
|
||||
|
17
flake.nix
17
flake.nix
@ -57,5 +57,22 @@
|
||||
'';
|
||||
in
|
||||
nixosTests // { inherit shellcheck; });
|
||||
formatter = forAllSystems (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "normalise_nix";
|
||||
runtimeInputs = with pkgs; [
|
||||
nixpkgs-fmt
|
||||
statix
|
||||
];
|
||||
text = ''
|
||||
set -o xtrace
|
||||
nixpkgs-fmt "$@"
|
||||
statix fix "$@"
|
||||
'';
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
let
|
||||
types = import ./types {
|
||||
inherit lib;
|
||||
inherit (config.disko) rootMountPoint;
|
||||
rootMountPoint = config.disko.rootMountPoint;
|
||||
};
|
||||
cfg = config.disko;
|
||||
in
|
||||
|
4
statix.toml
Normal file
4
statix.toml
Normal file
@ -0,0 +1,4 @@
|
||||
disabled = [
|
||||
"manual_inherit", # Prefer `inherit types;` instead of `types = types;`
|
||||
"manual_inherit_from", # Prefer `inherit (eval) options;` instead of `options = eval.options`.
|
||||
]
|
@ -2,7 +2,7 @@
|
||||
, makeDiskoTest ? (pkgs.callPackage ./lib.nix { }).makeDiskoTest
|
||||
}:
|
||||
let
|
||||
linux-bcachefs = pkgs.callPackage ../linux-testing-bcachefs.nix {};
|
||||
linux-bcachefs = pkgs.callPackage ../linux-testing-bcachefs.nix { };
|
||||
in
|
||||
makeDiskoTest {
|
||||
disko-config = ../example/bcachefs.nix;
|
||||
@ -14,11 +14,13 @@ makeDiskoTest {
|
||||
extraConfig = {
|
||||
boot.supportedFilesystems = [ "bcachefs" ];
|
||||
# disable zfs so we can support latest kernel
|
||||
nixpkgs.overlays = [(final: super: {
|
||||
zfs = super.zfs.overrideAttrs(_: {
|
||||
meta.platforms = [];
|
||||
});
|
||||
})];
|
||||
nixpkgs.overlays = [
|
||||
(final: super: {
|
||||
zfs = super.zfs.overrideAttrs (_: {
|
||||
meta.platforms = [ ];
|
||||
});
|
||||
})
|
||||
];
|
||||
boot.kernelPackages = pkgs.lib.mkForce (pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux-bcachefs));
|
||||
};
|
||||
}
|
||||
|
@ -3,15 +3,17 @@
|
||||
, pkgs ? (import <nixpkgs> { })
|
||||
}@args:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
inherit ((pkgs.callPackage ./lib.nix { inherit makeTest eval-config; })) makeDiskoTest;
|
||||
lib = pkgs.lib;
|
||||
makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest eval-config; }).makeDiskoTest;
|
||||
|
||||
evalTest = name: configFile: let
|
||||
disko-config = import configFile;
|
||||
in {
|
||||
"${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
|
||||
"${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
|
||||
};
|
||||
evalTest = name: configFile:
|
||||
let
|
||||
disko-config = import configFile;
|
||||
in
|
||||
{
|
||||
"${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
|
||||
"${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
|
||||
};
|
||||
|
||||
allTestFilenames =
|
||||
builtins.map (lib.removeSuffix ".nix") (
|
||||
@ -21,8 +23,8 @@ let
|
||||
);
|
||||
|
||||
allTests = lib.genAttrs allTestFilenames (test: import (./. + "/${test}.nix") { inherit makeDiskoTest pkgs; }) //
|
||||
evalTest "lvm-luks-example" ../example/config.nix // {
|
||||
standalone = (pkgs.nixos [ ../example/stand-alone/configuration.nix ]).config.system.build.toplevel;
|
||||
};
|
||||
evalTest "lvm-luks-example" ../example/config.nix // {
|
||||
standalone = (pkgs.nixos [ ../example/stand-alone/configuration.nix ]).config.system.build.toplevel;
|
||||
};
|
||||
in
|
||||
allTests
|
||||
|
@ -17,7 +17,7 @@
|
||||
, testBoot ? true # if we actually want to test booting or just create/mount
|
||||
}:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
lib = pkgs.lib;
|
||||
makeTest' = args:
|
||||
makeTest args {
|
||||
inherit pkgs;
|
||||
@ -100,7 +100,7 @@
|
||||
documentation.enable = false;
|
||||
|
||||
nix.settings = {
|
||||
substituters = lib.mkForce [];
|
||||
substituters = lib.mkForce [ ];
|
||||
hashed-mirrors = null;
|
||||
connect-timeout = 1;
|
||||
};
|
||||
|
@ -189,7 +189,7 @@ rec {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
inherit (attrs) default;
|
||||
default = attrs.default;
|
||||
description = "Mount script";
|
||||
};
|
||||
|
||||
@ -327,7 +327,7 @@ rec {
|
||||
};
|
||||
|
||||
subTypes = lib.mapAttrs (_: diskoLib.mkSubType) {
|
||||
nodev = ./nodev.nix;
|
||||
nodev = ./nodev.nix;
|
||||
btrfs = ./btrfs.nix;
|
||||
btrfs_subvol = ./btrfs_subvol.nix;
|
||||
filesystem = ./filesystem.nix;
|
||||
@ -343,6 +343,6 @@ rec {
|
||||
mdadm = ./mdadm.nix;
|
||||
mdraid = ./mdraid.nix;
|
||||
luks = ./luks.nix;
|
||||
disk = ./disk.nix;
|
||||
disk = ./disk.nix;
|
||||
};
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
vgchange -a y
|
||||
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues lvMounts)}
|
||||
'';
|
||||
inherit (lvMounts) fs;
|
||||
fs = lvMounts.fs;
|
||||
};
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
|
@ -54,8 +54,8 @@
|
||||
readOnly = true;
|
||||
default = [{
|
||||
fileSystems.${config.mountpoint} = {
|
||||
inherit (config) device;
|
||||
inherit (config) fsType;
|
||||
device = config.device;
|
||||
fsType = config.fsType;
|
||||
options = config.mountOptions;
|
||||
};
|
||||
}];
|
||||
|
@ -40,7 +40,7 @@
|
||||
default = dev: [{
|
||||
swapDevices = [{
|
||||
device = dev;
|
||||
inherit (config) randomEncryption;
|
||||
randomEncryption = config.randomEncryption;
|
||||
}];
|
||||
}];
|
||||
description = "NixOS configuration";
|
||||
|
Loading…
Reference in New Issue
Block a user