16 Commits

Author SHA1 Message Date
e065cde376 Use NixOS attributes for the install section 2023-09-18 19:27:14 +02:00
3bb0b550aa Add a RequiredBy dependency for remote-fs.target 2023-09-18 19:05:58 +02:00
e4cbcab81c Use a systemd mount directly for the nix store
Allows the LazyUnmount option and avoids the stage1 hack with
/nix//store.
2023-09-18 18:53:40 +02:00
77b41a90e2 Patch nix instead of using an override unit 2023-09-18 18:06:51 +02:00
1fc6891dc6 Remove nix-daemon.socket dependency of /nix/store
The dependency causes a cycle as the nix store will be mounted after the
network is ready, which itself depends on the socket.target which
requires the nix-daemon.socket to be ready too.
2023-09-18 17:28:47 +02:00
8c11c7460a Delay the mount until the network is ready 2023-09-18 16:07:46 +02:00
e6014511f5 Wait for the NFS hut store to be mounted 2023-09-18 15:50:37 +02:00
320c58ce48 Prevent the overlay to be mounted in stage1 2023-09-18 13:57:41 +02:00
d145ee9b2c Mount the overlay in /nix/store 2023-09-18 13:02:32 +02:00
140178d58e Begin the nix store overlay
We need to disable the read-only bind mount, so we can directly bind
mount the overlay.
2023-09-18 11:22:24 +02:00
d48f3b989a Enable direnv integration 2023-09-17 22:27:51 +02:00
653d411b9e Remove bscpkgs from the registry and nixPath
This is done to prevent accidental evaluations where the nixpkgs input
of bscpkgs is still pointing to a different version that the one
specified in the jungle flake. Instead use jungle#bscpkgs.X to get a
package from bscpkgs.
2023-09-15 12:00:33 +02:00
51c57dbc41 Add bscpkgs and nixpkgs top level attributes
Allows the evaluation of packages of the intermediate overlays.
2023-09-15 12:00:33 +02:00
33cd40160e Use hut packages as the default package set
Allows the user to directly access nixpkgs and bscpkgs from the top
level as `nix build jungle#htop` and `nix build jungle#bsc.ovni`.
2023-09-15 12:00:28 +02:00
a1e8cfea47 Don't fetch registry flakes from the net 2023-09-15 12:00:28 +02:00
5d72ee3da3 flake.lock: Update
Flake lock file updates:

• Updated input 'bscpkgs':
    'git+https://pm.bsc.es/gitlab/rarias/bscpkgs.git?ref=refs/heads/master&rev=6122fef92701701e1a0622550ac0fc5c2beb5906' (2023-09-07)
  → 'git+https://pm.bsc.es/gitlab/rarias/bscpkgs.git?ref=refs/heads/master&rev=3a4062ac04be6263c64a481420d8e768c2521b80' (2023-09-14)
2023-09-15 11:50:47 +02:00
9 changed files with 98 additions and 7 deletions

6
flake.lock generated
View File

@@ -29,11 +29,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1694077645, "lastModified": 1694708510,
"narHash": "sha256-72bvRBhq8Q8V6ibsR9lyBE92V2EC6C6Ek3J5cOM79So=", "narHash": "sha256-72bvRBhq8Q8V6ibsR9lyBE92V2EC6C6Ek3J5cOM79So=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "6122fef92701701e1a0622550ac0fc5c2beb5906", "rev": "3a4062ac04be6263c64a481420d8e768c2521b80",
"revCount": 860, "revCount": 862,
"type": "git", "type": "git",
"url": "https://pm.bsc.es/gitlab/rarias/bscpkgs.git" "url": "https://pm.bsc.es/gitlab/rarias/bscpkgs.git"
}, },

View File

@@ -26,6 +26,9 @@ in
lake2 = mkConf "lake2"; lake2 = mkConf "lake2";
}; };
packages.x86_64-linux.hut = self.nixosConfigurations.hut.pkgs; packages.x86_64-linux = self.nixosConfigurations.hut.pkgs // {
bscpkgs = bscpkgs.packages.x86_64-linux;
nixpkgs = nixpkgs.legacyPackages.x86_64-linux;
};
}; };
} }

View File

@@ -28,12 +28,13 @@
nix.nixPath = [ nix.nixPath = [
"nixpkgs=${nixpkgs}" "nixpkgs=${nixpkgs}"
"bscpkgs=${bscpkgs}"
"jungle=${theFlake.outPath}" "jungle=${theFlake.outPath}"
]; ];
nix.settings.flake-registry =
pkgs.writeText "global-registry.json" ''{"flakes":[],"version":2}'';
nix.registry.nixpkgs.flake = nixpkgs; nix.registry.nixpkgs.flake = nixpkgs;
nix.registry.bscpkgs.flake = bscpkgs;
nix.registry.jungle.flake = theFlake; nix.registry.jungle.flake = theFlake;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@@ -44,6 +45,8 @@
bsc.osumb bsc.osumb
]; ];
programs.direnv.enable = true;
systemd.services."serial-getty@ttyS0" = { systemd.services."serial-getty@ttyS0" = {
enable = true; enable = true;
wantedBy = [ "getty.target" ]; wantedBy = [ "getty.target" ];

View File

@@ -2,7 +2,6 @@
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
direnv
zsh-completions zsh-completions
nix-zsh-completions nix-zsh-completions
]; ];

View File

@@ -0,0 +1,69 @@
{ ... }:
{
# Don't make the nix store read-only, as this would prevent the overlay FS
# from being able to mount it.
boot.readOnlyNixStore = false;
# The nix-daemon.socket has an unnecessary dependency over the /nix/store
# mount point. But that mount point won't be provided until the network is
# ready. However, the network-address-eno1.service, has a dependency over
# sockets.target, causing a cycle.
# One solution is to make the nix-daemon.socket depend only on the socket
# patch (which is already covered by ConditionPathIsReadWrite =
# /nix/var/nix/daemon-socket), instead on the /nix/store.
#
# Using systemd.sockets.nix-daemon.unitConfig.RequiresMountsFor =
# "/nix/var/nix/daemon-socket" doesn't work, as the the mount options get
# added by systemd when the override config is merged with the one that Nix
# provides:
#
# owl2% sudo systemctl show nix-daemon.socket | grep RequiresMountsFor
# RequiresMountsFor=/nix/store /nix/var/nix/daemon-socket/socket /nix/var/nix/daemon-socket
#
# To fix this, the Nix package is patched to only depend on /nix/var instead.
# See ../../pkgs/overlay.nix for details.
# Mount the hut nix store via NFS in read-only mode.
fileSystems."/mnt/hut-nix-store" = {
device = "hut:/nix/store";
fsType = "nfs";
options = [ "ro" ];
};
# A workdir is also needed, so setup a permanent dir using tmpfiles.
systemd.tmpfiles.rules = [
"d /mnt/nix-work 0700 root root -"
];
# Mount an overlay in /nix/store using as lower layer the NFS store and upper
# layer the disk nix store. The destination is still the nix store in
# /nix/store (confusing). We need rw access, as the daemon need to write the
# lock files to build derivations locally. Use a systemd mount unit directly
# so we can specify the LazyUmount option and we avoid having it mounted
# in the stage1 before systemd.
systemd.mounts = [
{
what = "overlay";
type = "overlay";
where = "/nix/store";
# We need the local-fs.target to be ready, so the network interfaces can
# be configured to the network.target is reached. So make this a netdev
# mount.
options = "_netdev,lowerdir=/mnt/hut-nix-store,upperdir=/nix/store,workdir=/mnt/nix-work";
description = "Overlay /nix/store mount";
mountConfig = {
LazyUnmount = true;
};
# Run the unit after remote-fs-pre.target but before the remote-fs.target
after = [ "remote-fs-pre.target"];
before = [ "umount.target" "remote-fs.target" ];
# Install by using wantedBy over remote-fs.target
wantedBy = [ "remote-fs.target" ];
unitConfig = {
# We need to wait for the NFS mount
RequiresMountsFor = "/nix/store /mnt/hut-nix-store";
};
}
];
}

View File

@@ -5,6 +5,7 @@
../common/main.nix ../common/main.nix
../module/ceph.nix ../module/ceph.nix
../module/slurm-firewall.nix ../module/slurm-firewall.nix
../module/shared-nix-store.nix
]; ];
# Select the this using the ID to avoid mismatches # Select the this using the ID to avoid mismatches

View File

@@ -5,6 +5,7 @@
../common/main.nix ../common/main.nix
../module/ceph.nix ../module/ceph.nix
../module/slurm-firewall.nix ../module/slurm-firewall.nix
../module/shared-nix-store.nix
]; ];
# Select the this using the ID to avoid mismatches # Select the this using the ID to avoid mismatches

11
pkgs/nix-socket.patch Normal file
View File

@@ -0,0 +1,11 @@
--- a/misc/systemd/nix-daemon.socket.in 1970-01-01 01:00:01.000000000 +0100
+++ b/misc/systemd/nix-daemon.socket.in 2023-09-18 17:53:32.351760208 +0200
@@ -1,7 +1,7 @@
[Unit]
Description=Nix Daemon Socket
Before=multi-user.target
-RequiresMountsFor=@storedir@
+RequiresMountsFor=@localstatedir@
ConditionPathIsReadWrite=@localstatedir@/nix/daemon-socket
[Socket]

View File

@@ -32,4 +32,8 @@ final: prev:
lua = prev.lua5_4; lua = prev.lua5_4;
fmt = prev.fmt_8; fmt = prev.fmt_8;
}) ceph ceph-client; }) ceph ceph-client;
nix = prev.nix.overrideAttrs (old: {
patches = old.patches ++ [ ./nix-socket.patch ];
});
} }