Skip to content

Commit

Permalink
feat: move more packages to overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Dec 8, 2024
1 parent 425efd5 commit 6307f71
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 56 deletions.
9 changes: 8 additions & 1 deletion flake-modules/scripts.nix → flake-modules/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
in
{
packages = {
inherit (pkgs) system-manager system-setup;
inherit (pkgs)
system-manager
system-setup
findgpu
userctl
build-apptainer
build-container
;
system-install = pkgs.writeShellApplication {
name = "system-install";
text = ''
Expand Down
3 changes: 3 additions & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
nixglhost
uv
findgpu
userctl
build-apptainer
build-container
];
};
}
40 changes: 0 additions & 40 deletions modules/images.nix

This file was deleted.

20 changes: 20 additions & 0 deletions modules/registry.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ in
path = inputs.nixpkgs.outPath;
};
}
{
from = {
type = "indirect";
id = "stable";
};
to = {
type = "path";
path = inputs.nixpkgs.outPath;
};
}
{
from = {
type = "indirect";
id = "unstable";
};
to = {
type = "path";
path = inputs.nixpkgs-unstable.outPath;
};
}
];
}
);
Expand Down
15 changes: 0 additions & 15 deletions modules/users.nix

This file was deleted.

19 changes: 19 additions & 0 deletions overlays/build-apptainer.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
writeShellApplication,
lib,
apptainer,
build-container,
}:
writeShellApplication {
name = "build-apptainer";
text = ''
if [ "$#" -lt 1 ]; then
echo "Usage: $0 IMAGE_NAME [OUTPUT_FOLDER=.]" >&2
exit 1
fi
cd "''${2:-.}" || exit 1
${lib.getExe build-container} "$1" # we already changed to the output folder
${lib.getExe apptainer} build "$1.sif" "docker-archive:$1.tar.gz"
rm "$1.tar.gz"
'';
}
24 changes: 24 additions & 0 deletions overlays/build-container.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
writeShellApplication,
lib,
nix,
pigz,
self,
}:
writeShellApplication {
# https://github.com/NixOS/nixpkgs/blob/aa9d4729cbc99dabacb50e3994dcefb3ea0f7447/pkgs/build-support/docker/default.nix#L490
name = "build-container";
text = ''
if [ "$#" -lt 1 ]; then
echo "Usage: $0 IMAGE_NAME [OUTPUT_FOLDER=.]" >&2
exit 1
fi
cd "''${2:-.}" || exit 1
BUILDER_SCRIPT="$1-builder.sh"
${lib.getExe nix} build --show-trace -o "$BUILDER_SCRIPT" "${self.outPath}#image-$1"
./"$BUILDER_SCRIPT" \
| ${lib.getExe' pigz "pigz"} -nTR \
> "$1.tar.gz"
rm "$BUILDER_SCRIPT"
'';
}
9 changes: 9 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ final: prev: {
"E501"
];
} (builtins.readFile ./findgpu.py);
userctl = final.writers.writePython3Bin "userctl" {
libraries = with final.python3Packages; [ typer ];
flakeIgnore = [
"E203"
"E501"
];
} (builtins.readFile ./userctl.py);
build-container = final.callPackage ./build-container.nix { inherit (inputs) self; };
build-apptainer = final.callPackage ./build-apptainer.nix { };
}
File renamed without changes.

0 comments on commit 6307f71

Please sign in to comment.