* Introduction
This is my NixOS configuration. It is a part of my monorepo, and this file automatically tangles
-to all the under the nix/ directory in my monorepo [[https://git.nullring.xyz/monorepo.git][git repository]]. My monorepo also stores my
+to all the under the nix/ directory in my monorepo [[https://ret2pop.net/gitweb/monorepo.git][git repository]]. My monorepo also stores my
website, as my website stores my [[file:elfeed.org][elfeed]] and [[file:emacs.org][emacs]] configurations. Additionally, I want to track
my emacs configuration with my Nix configuration. Having them in one repository means that my
emacs configuration is pinned to my flake.
"spontaneity"
# add hostnames here
];
+
system = "x86_64-linux";
+
pkgs = import nixpkgs { inherit system; };
+
generate = nixos-dns.utils.generate nixpkgs.legacyPackages."${system}";
+
dnsConfig = {
inherit (self) nixosConfigurations;
extraConfig = import ./dns/default.nix;
};
+
+ # function that generates all systems from hostnames
mkConfigs = map (hostname: {name = "${hostname}";
value = nixpkgs.lib.nixosSystem {
inherit system;
];
};
});
+
+ mkDiskoFiles = map (hostname: {
+ name = "${hostname}";
+ value = self.nixosConfigurations."${hostname}".config.monorepo.vars.myDiskoSpec;
+ });
+
in {
- # add new systems here
nixosConfigurations = builtins.listToAttrs (mkConfigs hostnames);
+ evalDisko = builtins.listToAttrs (mkDiskoFiles (builtins.filter (x: x != "installer") hostnames));
+
topology."${system}" = import nix-topology {
pkgs = import nixpkgs {
inherit system;
{ lib, ... }:
{
options.monorepo.vars = {
+ device = lib.mkOption {
+ type = lib.types.str;
+ default = "/dev/sda";
+ example = "/dev/nvme0n1";
+ description = "device that NixOS is installed to";
+ };
+
+ myDiskoSpec = lib.mkOption {
+ type = lib.types.attrs;
+ description = "retains a copy of the disko spec for reflection";
+ };
+
userName = lib.mkOption {
type = lib.types.str;
default = "preston";
This is the disko configuration for my continuity system. It features a boot and ext4 partition,
on disk /dev/sda. All my SATA disks have this location by default, but if you want to use nvme,
you will have to import that configuration in your ~systems/xxx/default.nix~.
-#+begin_src nix :tangle ../nix/disko/sda-simple.nix
- {
- disko.devices = {
- disk = {
- my-disk = {
- device = "/dev/sda";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- ESP = {
- type = "EF00";
- size = "500M";
- priority = 1;
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- mountOptions = [ "umask=0077" ];
+*** NVME
+For my nvme drives.
+#+begin_src nix :tangle ../nix/disko/drive-simple.nix
+ { lib, config, ... }:
+ let
+ spec = {
+ disko.devices = {
+ disk = {
+ my-disk = {
+ device = config.monorepo.vars.device;
+ type = "disk";
+ content = {
+ type = "gpt";
+ partitions = {
+ ESP = {
+ type = "EF00";
+ size = "500M";
+ priority = 1;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ mountOptions = [ "umask=0077" ];
+ };
};
- };
- root = {
- size = "100%";
- priority = 2;
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
+ root = {
+ size = "100%";
+ priority = 2;
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
};
};
};
};
};
};
+ in
+ {
+ monorepo.vars.myDiskoSpec = spec;
+ disko.devices = spec.disko.devices;
}
#+end_src
-*** NVME
-For my nvme drives.
-#+begin_src nix :tangle ../nix/disko/nvme-simple.nix
-{
- disko.devices = {
- disk = {
- my-disk = {
- device = "/dev/nvme0n1";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- ESP = {
- type = "EF00";
- size = "500M";
- priority = 1;
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- mountOptions = [ "umask=0077" ];
- };
- };
- root = {
- size = "100%";
- priority = 2;
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
- };
- };
- };
- };
- };
- };
- };
-}
-#+end_src
*** VDA
For my virtual machines.
-#+begin_src nix :tangle ../nix/disko/vda-simple.nix
- {
- disko.devices = {
- disk = {
- main = {
- device = "/dev/vda";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- boot = {
- size = "1M";
- type = "EF02";
- };
- root = {
- label = "disk-main-root";
- size = "100%";
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
+#+begin_src nix :tangle ../nix/disko/drive-bios.nix
+ { config, lib, ... }:
+ let
+ spec = {
+ disko.devices = {
+ disk = {
+ main = {
+ device = config.monorepo.vars.device;
+ type = "disk";
+ content = {
+ type = "gpt";
+ partitions = {
+ boot = {
+ size = "1M";
+ type = "EF02";
+ };
+ root = {
+ label = "disk-main-root";
+ size = "100%";
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
};
};
};
};
};
};
+ in
+ {
+ monorepo.vars.myDiskoSpec = spec;
+ disko.devices = spec.disko.devices;
}
#+end_src
** Home
++
(if config.monorepo.profiles.art.enable then (with pkgs; [
inkscape
- krita
+ # krita
]) else [])
++
(if config.monorepo.profiles.music.enable then (with pkgs; [
alsa-scarlett-gui
ardour
audacity
- blender
+ # blender
foxdot
fluidsynth
qjackctl
supercollider
inkscape
kdePackages.kdenlive
- kicad
+ # kicad
murmur
silver-searcher
]) else []);
g = "git";
v = "vim";
py = "python3";
- rb = "sudo nixos-rebuild switch --flake .#${systemHostName}";
+ rb = "sudo nixos-rebuild switch --flake $HOME/monorepo/nix#${systemHostName}";
nfu = "cd ~/monorepo/nix && git add . && git commit -m \"new flake lock\" && nix flake update";
usync = "rsync -azvP --chmod=\"Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r\" ~/website_html/ root@${config.monorepo.vars.remoteHost}:/var/www/ret2pop-website/";
usite
packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [
# wikipedia
- kiwix kiwix-tools
+ # kiwix kiwix-tools
# passwords
age sops
graphviz jq
# Apps
- octaveFull
+ # octaveFull
vesktop grim swww vim telegram-desktop
# Sound/media
(writeShellScriptBin "remote-build"
''
#!/bin/bash
- cd ~/monorepo/nix
- nixos-rebuild --use-remote-sudo --target-host "$1" switch --flake .#spontaneity
+ nixos-rebuild --sudo --ask-sudo-password --target-host "$1" switch --flake $HOME/monorepo/nix#spontaneity
''
)
(writeShellScriptBin "install-vps"
''
#!/bin/bash
- nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./systems/spontaneity/hardware-configuration.nix --flake .#spontaneity --target-host "$1"
+ nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config $HOME/monorepo/nix/systems/spontaneity/hardware-configuration.nix --flake $HOME/monorepo/nix#spontaneity --target-host "$1"
'')
] else [
pfetch
};
}
#+end_src
+** Includes
+These are the common includes for my systems.
+#+begin_src nix :tangle ../nix/systems/includes.nix
+ { config, lib, ... }:
+ {
+ imports = [
+ ./home.nix
+ ../modules/default.nix
+ ];
+ }
+#+end_src
** Continuity
This is pretty understandable, if you understand all the above.
#+begin_src nix :tangle ../nix/systems/continuity/default.nix
{ ... }:
{
imports = [
- ../../modules/default.nix
- ../../disko/sda-simple.nix
- ../home.nix
+ ../../disko/drive-simple.nix
+ ../includes.nix
];
+ config = {
+ # drive to install to
+ monorepo.vars.device = "/dev/sda";
+ };
}
#+end_src
*** Home
{ config, lib, home-manager, ... }:
{
imports = [
- ../../modules/default.nix
- ../../disko/nvme-simple.nix
- ../home.nix
+ ../includes.nix
+ ../../disko/drive-simple.nix
];
config = {
monorepo = {
+ vars.device = "/dev/nvme0n1";
profiles = {
server.enable = false;
cuda.enable = true;
{ config, lib, ... }:
{
imports = [
+ ../includes.nix
# nixos-anywhere generates this file
./hardware-configuration.nix
- ../../disko/vda-simple.nix
- ../../modules/default.nix
- ../home.nix
+ ../../disko/drive-bios.nix
];
config = {
monorepo = {
+ vars.device = "/dev/vda";
profiles = {
server.enable = true;
ttyonly.enable = true;
exit 1
fi
+ cd "$HOME"
+
+ ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
+
gum style --border normal --margin "1" --padding "1 2" "Choose a system to install or select `new` in order to create a new system."
SYSTEM="$(gum choose $(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New"))"
if [[ "$DRIVE" == "New" ]]; then
gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file."
- DRIVE="$(gum input --placeholder "drive file name (ex: my_sda.nix)")"
+ DRIVE="$(gum input --placeholder "drive file name (ex: partition_scheme.nix)")"
fi
fi
-
- ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
-
- cd "$HOME"
-
if [ ! -d "$HOME/monorepo/" ]; then
git clone ${commits.monorepoUrl}
cd "$HOME/monorepo"
{ ... }:
{
imports = [
- ../../modules/default.nix
+ ../includes.nix
../../disko/$DRIVE
- ../home.nix
];
+ # CHANGEME
+ config.monorepo.vars.drive = "/dev/sda";
}
EOF
gum input --placeholder "Press Enter to continue" >/dev/null
vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
+ gum style --border normal --margin "1" --padding "1 2" "Edit the home default.nix with options."
+ gum input --placeholder "Press Enter to continue" >/dev/null
+ vim "$HOME/monorepo/nix/systems/$SYSTEM/home.nix"
+
sed -i "/hostnames = \[/,/];/ { /];/i \ \"your-hostname-$SYSTEM\" }" "$HOME/monorepo/nix/flake.nix"
if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then
- cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE"
+ cp "$HOME/monorepo/nix/disko/drive-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE"
gum style --border normal --margin "1" --padding "1 2" "Edit the drive file with your preferred partitioning scheme."
gum input --placeholder "Press Enter to continue" >/dev/null
vim "$HOME/monorepo/nix/disko/$DRIVE"
cd "$HOME/monorepo" && git add . && cd "$HOME"
fi
+ nix --extra-experimental-features 'nix-command flakes' eval "$HOME/monorepo/nix#evalDisko.$SYSTEM" > "$HOME/drive.nix"
+
gum style --border normal --margin "1" --padding "1 2" "Formatting the drive is destructive!"
if gum confirm "Are you sure you want to continue?"; then
echo "Proceeding..."
exit 1
fi
- sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE"
+ sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/drive.nix"
+
cd /mnt
sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM"
--- /dev/null
+{ config, lib, ... }:
+let
+ spec = {
+ disko.devices = {
+ disk = {
+ main = {
+ device = config.monorepo.vars.device;
+ type = "disk";
+ content = {
+ type = "gpt";
+ partitions = {
+ boot = {
+ size = "1M";
+ type = "EF02";
+ };
+ root = {
+ label = "disk-main-root";
+ size = "100%";
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+in
+{
+ monorepo.vars.myDiskoSpec = spec;
+ disko.devices = spec.disko.devices;
+}
--- /dev/null
+{ lib, config, ... }:
+let
+ spec = {
+ disko.devices = {
+ disk = {
+ my-disk = {
+ device = config.monorepo.vars.device;
+ type = "disk";
+ content = {
+ type = "gpt";
+ partitions = {
+ ESP = {
+ type = "EF00";
+ size = "500M";
+ priority = 1;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ mountOptions = [ "umask=0077" ];
+ };
+ };
+ root = {
+ size = "100%";
+ priority = 2;
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+in
+{
+ monorepo.vars.myDiskoSpec = spec;
+ disko.devices = spec.disko.devices;
+}
+++ /dev/null
-{
- disko.devices = {
- disk = {
- my-disk = {
- device = "/dev/nvme0n1";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- ESP = {
- type = "EF00";
- size = "500M";
- priority = 1;
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- mountOptions = [ "umask=0077" ];
- };
- };
- root = {
- size = "100%";
- priority = 2;
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
- };
- };
- };
- };
- };
- };
- };
-}
+++ /dev/null
-{
- disko.devices = {
- disk = {
- my-disk = {
- device = "/dev/sda";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- ESP = {
- type = "EF00";
- size = "500M";
- priority = 1;
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- mountOptions = [ "umask=0077" ];
- };
- };
- root = {
- size = "100%";
- priority = 2;
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
- };
- };
- };
- };
- };
- };
- };
-}
+++ /dev/null
-{
- disko.devices = {
- disk = {
- main = {
- device = "/dev/vda";
- type = "disk";
- content = {
- type = "gpt";
- partitions = {
- boot = {
- size = "1M";
- type = "EF02";
- };
- root = {
- label = "disk-main-root";
- size = "100%";
- content = {
- type = "filesystem";
- format = "ext4";
- mountpoint = "/";
- };
- };
- };
- };
- };
- };
- };
-}
]
},
"locked": {
- "lastModified": 1755519972,
- "narHash": "sha256-bU4nqi3IpsUZJeyS8Jk85ytlX61i4b0KCxXX9YcOgVc=",
+ "lastModified": 1756733629,
+ "narHash": "sha256-dwWGlDhcO5SMIvMSTB4mjQ5Pvo2vtxvpIknhVnSz2I8=",
"owner": "nix-community",
"repo": "disko",
- "rev": "4073ff2f481f9ef3501678ff479ed81402caae6d",
+ "rev": "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1",
"type": "github"
},
"original": {
]
},
"locked": {
- "lastModified": 1753592768,
- "narHash": "sha256-oV695RvbAE4+R9pcsT9shmp6zE/+IZe6evHWX63f2Qg=",
+ "lastModified": 1756679287,
+ "narHash": "sha256-Xd1vOeY9ccDf5VtVK12yM0FS6qqvfUop8UQlxEB+gTQ=",
"owner": "nix-community",
"repo": "home-manager",
- "rev": "fc3add429f21450359369af74c2375cb34a2d204",
+ "rev": "07fc025fe10487dd80f2ec694f1cd790e752d0e8",
"type": "github"
},
"original": {
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1755186698,
- "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
+ "lastModified": 1757068644,
+ "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
+ "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
"type": "github"
},
"original": {
},
"nixpkgs_3": {
"locked": {
- "lastModified": 1755186698,
- "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
+ "lastModified": 1757068644,
+ "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
+ "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
"type": "github"
},
"original": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
- "lastModified": 1755566258,
- "narHash": "sha256-bLDKNtjyDjMOK6w2dsRRRPKr2GzcKOdIjsiJd2FbZuA=",
+ "lastModified": 1757237279,
+ "narHash": "sha256-u0cJc2Thq0QF8fzTSy3617E83aAPsGKjnIKgaZBXW+I=",
"owner": "nix-community",
"repo": "NUR",
- "rev": "b54ab372b6c2831be68f7302142bdfae08204756",
+ "rev": "4dcb0b2bddd4456fc10d7f29862a1f1b1fd304e9",
"type": "github"
},
"original": {
"spontaneity"
# add hostnames here
];
+
system = "x86_64-linux";
+
pkgs = import nixpkgs { inherit system; };
+
generate = nixos-dns.utils.generate nixpkgs.legacyPackages."${system}";
+
dnsConfig = {
inherit (self) nixosConfigurations;
extraConfig = import ./dns/default.nix;
};
+
+ # function that generates all systems from hostnames
mkConfigs = map (hostname: {name = "${hostname}";
value = nixpkgs.lib.nixosSystem {
inherit system;
];
};
});
+
+ mkDiskoFiles = map (hostname: {
+ name = "${hostname}";
+ value = self.nixosConfigurations."${hostname}".config.monorepo.vars.myDiskoSpec;
+ });
+
in {
- # add new systems here
nixosConfigurations = builtins.listToAttrs (mkConfigs hostnames);
+ evalDisko = builtins.listToAttrs (mkDiskoFiles (builtins.filter (x: x != "installer") hostnames));
+
topology."${system}" = import nix-topology {
pkgs = import nixpkgs {
inherit system;
++
(if config.monorepo.profiles.art.enable then (with pkgs; [
inkscape
- krita
+ # krita
]) else [])
++
(if config.monorepo.profiles.music.enable then (with pkgs; [
alsa-scarlett-gui
ardour
audacity
- blender
+ # blender
foxdot
fluidsynth
qjackctl
supercollider
inkscape
kdePackages.kdenlive
- kicad
+ # kicad
murmur
silver-searcher
]) else []);
packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [
# wikipedia
- kiwix kiwix-tools
+ # kiwix kiwix-tools
# passwords
age sops
graphviz jq
# Apps
- octaveFull
+ # octaveFull
vesktop grim swww vim telegram-desktop
# Sound/media
(writeShellScriptBin "remote-build"
''
#!/bin/bash
-cd ~/monorepo/nix
-nixos-rebuild --use-remote-sudo --target-host "$1" switch --flake .#spontaneity
+nixos-rebuild --sudo --ask-sudo-password --target-host "$1" switch --flake $HOME/monorepo/nix#spontaneity
''
)
(writeShellScriptBin "install-vps"
''
#!/bin/bash
-nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./systems/spontaneity/hardware-configuration.nix --flake .#spontaneity --target-host "$1"
+nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config $HOME/monorepo/nix/systems/spontaneity/hardware-configuration.nix --flake $HOME/monorepo/nix#spontaneity --target-host "$1"
'')
] else [
pfetch
g = "git";
v = "vim";
py = "python3";
- rb = "sudo nixos-rebuild switch --flake .#${systemHostName}";
+ rb = "sudo nixos-rebuild switch --flake $HOME/monorepo/nix#${systemHostName}";
nfu = "cd ~/monorepo/nix && git add . && git commit -m \"new flake lock\" && nix flake update";
usync = "rsync -azvP --chmod=\"Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r\" ~/website_html/ root@${config.monorepo.vars.remoteHost}:/var/www/ret2pop-website/";
usite
{ lib, ... }:
{
options.monorepo.vars = {
+ device = lib.mkOption {
+ type = lib.types.str;
+ default = "/dev/sda";
+ example = "/dev/nvme0n1";
+ description = "device that NixOS is installed to";
+ };
+
+ myDiskoSpec = lib.mkOption {
+ type = lib.types.attrs;
+ description = "retains a copy of the disko spec for reflection";
+ };
+
userName = lib.mkOption {
type = lib.types.str;
default = "preston";
{ config, lib, home-manager, ... }:
{
imports = [
- ../../modules/default.nix
- ../../disko/nvme-simple.nix
- ../home.nix
+ ../includes.nix
+ ../../disko/drive-simple.nix
];
config = {
monorepo = {
+ vars.device = "/dev/nvme0n1";
profiles = {
server.enable = false;
cuda.enable = true;
{ ... }:
{
imports = [
- ../../modules/default.nix
- ../../disko/sda-simple.nix
- ../home.nix
+ ../../disko/drive-simple.nix
+ ../includes.nix
];
+ config = {
+ # drive to install to
+ monorepo.vars.device = "/dev/sda";
+ };
}
--- /dev/null
+{ config, lib, ... }:
+{
+ imports = [
+ ./home.nix
+ ../modules/default.nix
+ ];
+}
{
diskoCommitHash = "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1";
- monorepoCommitHash = "af3c15c43c65fd77aab441f4c657aeaa74cc67d5";
+ monorepoCommitHash = "8f4f46e59ad0b7c5662a417d10f3074f17c962c3";
monorepoUrl = "https://github.com/ret2pop/monorepo";
}
exit 1
fi
+cd "$HOME"
+
+ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
+
gum style --border normal --margin "1" --padding "1 2" "Choose a system to install or select `new` in order to create a new system."
-SYSTEM="$(gum choose "$(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New")")"
+SYSTEM="$(gum choose $(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New"))"
if [[ "$SYSTEM" == "New" ]]; then
gum style --border normal --margin "1" --padding "1 2" "Choose a system name"
SYSTEM="$(gum input --placeholder "system name")"
-fi
-gum style --border normal --margin "1" --padding "1 2" "Select a drive file or create a new drive file."
-DRIVE="$(gum choose "$(find "$HOME/monorepo/nix/disko" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | printf "New")")"
+ gum style --border normal --margin "1" --padding "1 2" "Select a drive file or create a new drive file."
+ DRIVE="$(gum choose $(find "$HOME/monorepo/nix/disko" -mindepth 1 -maxdepth 1 -type f -printf "%f\n"; printf "New"))"
-if [[ "$DRIVE" == "New" ]]; then
- gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file."
- SYSTEM="$(gum input --placeholder "drive file name (ex: my_sda.nix)")"
+ if [[ "$DRIVE" == "New" ]]; then
+ gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file."
+ DRIVE="$(gum input --placeholder "drive file name (ex: partition_scheme.nix)")"
+ fi
fi
-ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
-
-cd "$HOME"
-
if [ ! -d "$HOME/monorepo/" ]; then
git clone ${commits.monorepoUrl}
cd "$HOME/monorepo"
{ ... }:
{
imports = [
- ../../modules/default.nix
+ ../includes.nix
../../disko/$DRIVE
- ../home.nix
];
+ # CHANGEME
+ config.monorepo.vars.drive = "/dev/sda";
}
EOF
gum input --placeholder "Press Enter to continue" >/dev/null
vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
+ gum style --border normal --margin "1" --padding "1 2" "Edit the home default.nix with options."
+ gum input --placeholder "Press Enter to continue" >/dev/null
+ vim "$HOME/monorepo/nix/systems/$SYSTEM/home.nix"
+
sed -i "/hostnames = \[/,/];/ { /];/i \ \"your-hostname-$SYSTEM\" }" "$HOME/monorepo/nix/flake.nix"
if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then
- cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE"
+ cp "$HOME/monorepo/nix/disko/drive-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE"
gum style --border normal --margin "1" --padding "1 2" "Edit the drive file with your preferred partitioning scheme."
gum input --placeholder "Press Enter to continue" >/dev/null
vim "$HOME/monorepo/nix/disko/$DRIVE"
cd "$HOME/monorepo" && git add . && cd "$HOME"
fi
-if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then
- echo "error: you should create a new system if you use a drive file that is not in the repo."
- exit 1
-fi
+nix --extra-experimental-features 'nix-command flakes' eval "$HOME/monorepo/nix#evalDisko.$SYSTEM" > "$HOME/drive.nix"
gum style --border normal --margin "1" --padding "1 2" "Formatting the drive is destructive!"
if gum confirm "Are you sure you want to continue?"; then
exit 1
fi
-sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE"
+sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/drive.nix"
+
cd /mnt
sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM"
{ config, lib, ... }:
{
imports = [
+ ../includes.nix
# nixos-anywhere generates this file
./hardware-configuration.nix
- ../../disko/vda-simple.nix
- ../../modules/default.nix
- ../home.nix
+ ../../disko/drive-bios.nix
];
config = {
monorepo = {
+ vars.device = "/dev/vda";
profiles = {
server.enable = true;
ttyonly.enable = true;