-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use flake modules for better structure
- Loading branch information
Showing
5 changed files
with
148 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
lib, | ||
inputs, | ||
self, | ||
pkgs, | ||
system, | ||
lib', | ||
... | ||
}: let | ||
specialArgs = { | ||
inherit inputs self lib'; | ||
}; | ||
in { | ||
flake = { | ||
systemConfigs.default = inputs.system-manager.lib.makeSystemConfig { | ||
extraSpecialArgs = specialArgs; | ||
modules = [ | ||
../modules | ||
../options | ||
{ | ||
_module.args.pkgs = lib.mkForce pkgs; | ||
nixpkgs.hostPlatform = system; | ||
} | ||
]; | ||
}; | ||
nixosConfigurations.default = inputs.nixpkgs.lib.nixosSystem { | ||
inherit system pkgs specialArgs; | ||
modules = [ | ||
../modules | ||
({modulesPath, ...}: { | ||
# use virtual machine profile, otherwise file systems need to be defined | ||
imports = [ | ||
"${modulesPath}/virtualisation/lxc-container.nix" | ||
]; | ||
system.stateVersion = "23.11"; | ||
}) | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
inputs, | ||
lib, | ||
lib', | ||
... | ||
}: let | ||
system = "x86_64-linux"; | ||
pkgs = import inputs.nixpkgs { | ||
inherit system; | ||
config = { | ||
allowUnfree = true; | ||
cudaSupport = true; | ||
}; | ||
overlays = lib.singleton ( | ||
final: prev: { | ||
apptainer = prev.apptainer.override { | ||
enableNvidiaContainerCli = false; | ||
}; | ||
system-manager = inputs.system-manager.packages.${system}.default; | ||
} | ||
); | ||
}; | ||
in { | ||
imports = lib'.flocken.getModules ./.; | ||
systems = lib.singleton system; | ||
_module.args = { | ||
inherit system pkgs; | ||
}; | ||
perSystem = {config, ...}: { | ||
_module.args = { | ||
inherit pkgs; | ||
}; | ||
packages.default = config.packages.install; | ||
checks = config.packages; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{...}: { | ||
perSystem = { | ||
config, | ||
pkgs, | ||
... | ||
}: { | ||
packages = { | ||
image-base = pkgs.callPackage ../images/base.nix {}; | ||
image-jupyter = pkgs.callPackage ../images/jupyter.nix { | ||
base = config.packages.image-base; | ||
}; | ||
image-poetry = pkgs.callPackage ../images/poetry.nix { | ||
base = config.packages.image-base; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
lib, | ||
self, | ||
... | ||
}: { | ||
perSystem = {pkgs, ...}: { | ||
packages = { | ||
manager = lib.getExe pkgs.system-manager; | ||
install = pkgs.writeShellApplication { | ||
name = "system-manager-rebuild"; | ||
text = '' | ||
set -x #echo on | ||
exec ${lib.getExe pkgs.system-manager} "''${1:-switch}" --flake ${self} "''${@:2}" | ||
''; | ||
}; | ||
uninstall = pkgs.writeShellApplication { | ||
name = "system-manager-uninstall"; | ||
text = '' | ||
set -x #echo on | ||
exec ${lib.getExe pkgs.system-manager} deactivate "''$@" | ||
''; | ||
}; | ||
setup = pkgs.writeShellApplication { | ||
name = "system-manager-setup"; | ||
text = '' | ||
# only root possible | ||
if [ "$(id -u)" -ne 0 ]; then | ||
echo "This script must be run as root" >&2 | ||
exit 1 | ||
fi | ||
set -x #echo on | ||
# set up nix | ||
cp -f ${../etc/nix.conf} /etc/nix/nix.conf | ||
systemctl restart nix-daemon | ||
# set up cuda support for oci engines like podman | ||
nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml | ||
chmod -R 755 /etc/cdi | ||
# set compute mode to exclusive process (https://stackoverflow.com/a/50056586) | ||
nvidia-smi -c 3 | ||
# disable default motd | ||
chmod -x /etc/update-motd.d/* | ||
''; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters