patos/flake.nix

71 lines
2 KiB
Nix
Raw Normal View History

2024-09-12 21:57:01 +02:00
{
description = "PatOS is a minimal, immutable Linux distribution specialized for the Patagia Platform.";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
2024-09-12 21:57:01 +02:00
};
2024-09-17 23:02:53 +02:00
outputs =
{
self,
flake-utils,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = {
default = self.packages.${system}.image;
image = pkgs.writeShellScriptBin "image" ''
echo "make UKI..."
${self.packages.${system}.systemd.out}/bin/ukify build \
--linux ${self.packages.${system}.kernel.kernel}/bzImage \
--initrd ./out/initrd.gz \
--cmdline "console=ttyS0" \
-o patos.uki
'';
kernel = pkgs.callPackage ./kernel { };
initrd = pkgs.writeShellScriptBin "mkinitrd" ''
echo "make initrd..."
mkdir -p out/lib
# copy systemd
cp -r ${self.packages.${system}.systemd.out}/* out/
# get shared libs
pushd out
find . -type f -executable | xargs ldd | awk '{print $3}' | grep -v systemd | sort -u | xargs cp -t lib
# gen initrd
find . -print0 | ${pkgs.lib.getExe pkgs.cpio} --null --owner=root:root -o --format=newc | ${pkgs.lib.getExe pkgs.gzip} -9 > initrd.gz
'';
systemd = pkgs.callPackage ./systemd { };
};
checks = {
simple-test = pkgs.runCommand "simple-test" { } ''
${self.packages.${system}.default}/bin/my-program
touch $out
'';
};
formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
erofs-utils
just
nixd
nixfmt-rfc-style
squashfs-tools-ng
];
};
}
);
2024-09-12 21:57:01 +02:00
}