Skip to content

Instantly share code, notes, and snippets.

@Jayman2000
Last active February 15, 2024 19:45
Show Gist options
  • Save Jayman2000/60b483659e89283716582ac38856dca6 to your computer and use it in GitHub Desktop.
Save Jayman2000/60b483659e89283716582ac38856dca6 to your computer and use it in GitHub Desktop.
Nix expressions that will help me test out a Disko PR: <https://github.com/nix-community/disko/>
# 🅭🄍1.0 This file is dedicated to the public domain using the CC0 1.0 Universal
# Public Domain Dedication:
# <https://creativecommons.org/publicdomain/zero/1.0/>
{ diskoDir }:
let
configuration = { pkgs, modulesPath, ... }: {
imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" ];
# This will (hopefully) make the ISO build faster.
isoImage.squashfsCompression = "lz4";
systemd.services.disko-test = {
description = "test for running disko in a systemd service";
# disko will fail in nix-build isn’t on the PATH.
path = [ pkgs.nix ];
script = let
diskoPackage = pkgs.callPackage "${diskoDir}/package.nix" { };
diskoConfig = ./disko-config.nix;
in ''
${diskoPackage}/bin/disko --mode disko ${diskoConfig}
'';
};
};
pkgs = import <nixpkgs> { };
nixOSPackage = pkgs.nixos configuration;
in nixOSPackage.config.system.build.isoImage
# This file was copied from
# <https://github.com/nix-community/disko/blob/d07de570ba05cec2807d058daaa044f6955720c7/example/simple-efi.nix>.
# Here’s the license for that repository:
#
# MIT License
#
# Copyright (c) 2022 Nix community projects
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
{
disko.devices = {
disk = {
main = {
device = "/dev/vda";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "500M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment