Compare commits
No commits in common. "09af51fce864a4e7b033b5dd96084628ee996ed0" and "31a2504bea966251a391646380ca781ab15588ab" have entirely different histories.
09af51fce8
...
31a2504bea
|
@ -1,13 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Wrapper script for nixos-rebuild
|
# Wrapper script for nixos-rebuild
|
||||||
|
|
||||||
|
#set -e
|
||||||
|
|
||||||
# Configuration parameters
|
# Configuration parameters
|
||||||
operation="switch" # The nixos-rebuild operation to use
|
operation="switch" # The nixos-rebuild operation to use
|
||||||
hostname=$(hostname) # The name of the host to build
|
hostname=$(hostname) # The name of the host to build
|
||||||
flakeDir="." # Path to the flake file (and optionally the hostname)
|
flakeDir="." # Path to the flake file (and optionally the hostname)
|
||||||
remainingArgs="" # All remaining arguments that haven't been processed
|
remainingArgs="" # All remaining arguments that haven't been processed
|
||||||
commit=true # Whether to update git (true by default)
|
commit=true # Whether to update git (true by default)
|
||||||
buildHost="" # Which host to build the system on.
|
buildHost="" # Which host to build the system on.
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage: nixos-upgrade-script.sh [-o|--operation operation] [-f|--flake path-to-flake-file] [extra nixos-rebuild parameters]"
|
echo "Usage: nixos-upgrade-script.sh [-o|--operation operation] [-f|--flake path-to-flake-file] [extra nixos-rebuild parameters]"
|
||||||
|
@ -22,15 +24,14 @@ function usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_operation {
|
function run_operation {
|
||||||
echo "Full operation: nixos-rebuild $1 --flake $flakeDir#$hostname $( [ "$buildHost" != "" ] && echo "--build-host $buildHost" ) $remainingArgs --use-remote-sudo"
|
echo "Full operation: nixos-rebuild $1 --flake $flakeDir#$hostname $( [ "$buildHost" != "" ] && echo "--build-host $buildHost" ) $remainingArgs"
|
||||||
nixos-rebuild $operation --flake .#$hostname $remainingArgs --use-remote-sudo
|
|
||||||
|
|
||||||
# Only request super-user permission if we're switching
|
# Only request super-user permission if we're switching
|
||||||
#if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
|
if [[ "$1" =~ ^(switch|boot|test)$ ]]; then
|
||||||
# nixos-rebuild $operation --flake .#$hostname $remainingArgs --use-remote-sudo
|
sudo nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
||||||
#else
|
else
|
||||||
# nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
nixos-rebuild $operation --flake .#$hostname $remainingArgs
|
||||||
#fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
|
||||||
|
@ -84,6 +85,11 @@ if [ $commit = true ]; then
|
||||||
git push
|
git push
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If this is a remote build, run the build as non-sudo first
|
||||||
|
if [[ "$buildHost" != "" ]]; then
|
||||||
|
run_operation "build"
|
||||||
|
fi
|
||||||
|
|
||||||
run_operation $operation
|
run_operation $operation
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
28
flake.lock
28
flake.lock
|
@ -196,21 +196,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lib": {
|
|
||||||
"locked": {
|
|
||||||
"dir": "lib",
|
|
||||||
"lastModified": 1726973702,
|
|
||||||
"narHash": "sha256-3MhRNhPikBf/rfqI+z1kprqeyR8OZFgCL6G6ZTFBjR8=",
|
|
||||||
"rev": "d7762a5a78273ffb76da6f6902245983143f63f6",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://git.auxolotl.org/api/v1/repos/auxolotl/labs/archive/d7762a5a78273ffb76da6f6902245983143f63f6.tar.gz?rev=d7762a5a78273ffb76da6f6902245983143f63f6"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"dir": "lib",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lix": {
|
"lix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -267,11 +252,11 @@
|
||||||
},
|
},
|
||||||
"nixos-hardware": {
|
"nixos-hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727528503,
|
"lastModified": 1727437159,
|
||||||
"narHash": "sha256-wZd8OqPeQt9h7VU2VxsW4Vx0Ze+3hDLHql3pNbIMYEU=",
|
"narHash": "sha256-v4qLwEw5OmprgQZTT7KZMNU7JjXJzRypw8+Cw6++fWk=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "c1f051bf032273b9f0e707c8826eb25122d279fa",
|
"rev": "d830ad47cc992b4a46b342bbc79694cbd0e980b2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -331,11 +316,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727397532,
|
"lastModified": 1727264057,
|
||||||
"narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=",
|
"narHash": "sha256-KQPI8CTTnB9CrJ7LrmLC4VWbKZfljEPBXOFGZFRpxao=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f65141456289e81ea0d5a05af8898333cab5c53d",
|
"rev": "759537f06e6999e141588ff1c9be7f3a5c060106",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -377,7 +362,6 @@
|
||||||
"gnome-triplebuffering": "gnome-triplebuffering",
|
"gnome-triplebuffering": "gnome-triplebuffering",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"lanzaboote": "lanzaboote",
|
"lanzaboote": "lanzaboote",
|
||||||
"lib": "lib",
|
|
||||||
"lix-module": "lix-module",
|
"lix-module": "lix-module",
|
||||||
"nix-flatpak": "nix-flatpak",
|
"nix-flatpak": "nix-flatpak",
|
||||||
"nixos-hardware": "nixos-hardware",
|
"nixos-hardware": "nixos-hardware",
|
||||||
|
|
35
flake.nix
35
flake.nix
|
@ -10,25 +10,6 @@
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
||||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
# Repository for Gnome triple buffering patch
|
|
||||||
# For details, see https://wiki.nixos.org/wiki/GNOME#Dynamic_triple_buffering
|
|
||||||
gnome-triplebuffering = {
|
|
||||||
url = "gitlab:vanvugt/mutter/triple-buffering-v4-46?host=gitlab.gnome.org";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Home-manager support
|
|
||||||
home-manager = {
|
|
||||||
url = "github:nix-community/home-manager/release-24.05";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
# SecureBoot support
|
|
||||||
lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1";
|
|
||||||
|
|
||||||
# Aux lib
|
|
||||||
lib.url = "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz?dir=lib";
|
|
||||||
|
|
||||||
# Use Lix in place of Nix.
|
# Use Lix in place of Nix.
|
||||||
# If you'd rather use regular Nix, remove `lix-module.nixosModules.default` from the `modules` section below.
|
# If you'd rather use regular Nix, remove `lix-module.nixosModules.default` from the `modules` section below.
|
||||||
# To learn more about Lix, see https://lix.systems/
|
# To learn more about Lix, see https://lix.systems/
|
||||||
|
@ -40,8 +21,24 @@
|
||||||
# Flatpak support
|
# Flatpak support
|
||||||
nix-flatpak.url = "github:gmodena/nix-flatpak/v0.4.1";
|
nix-flatpak.url = "github:gmodena/nix-flatpak/v0.4.1";
|
||||||
|
|
||||||
|
# SecureBoot support
|
||||||
|
lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1";
|
||||||
|
|
||||||
# NixOS hardware quirks
|
# NixOS hardware quirks
|
||||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||||
|
|
||||||
|
# Home-manager support
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager/release-24.05";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Repository for Gnome triple buffering patch
|
||||||
|
# For details, see https://wiki.nixos.org/wiki/GNOME#Dynamic_triple_buffering
|
||||||
|
gnome-triplebuffering = {
|
||||||
|
url = "gitlab:vanvugt/mutter/triple-buffering-v4-46?host=gitlab.gnome.org";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
|
|
|
@ -61,11 +61,9 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Improve Khanda's responsiveness
|
|
||||||
kernel.sysctl = {
|
kernel.sysctl = {
|
||||||
"vm.swappiness" = 20; # Try to reduce swappiness - Khanda hates paging, even to NVMe storage
|
# Try to reduce swappiness - Khanda hates paging, even to NVMe storage
|
||||||
"vm.vfs_cache_pressure" = 50; # https://wiki.archlinux.org/title/Sysctl#VFS_cache
|
"vm.swappiness" = 20;
|
||||||
"kernel.core_pattern" = "|${pkgs.coreutils}/bin/false"; # Disable core dumps per https://wiki.archlinux.org/title/Core_dump#Using_sysctl
|
|
||||||
};
|
};
|
||||||
|
|
||||||
kernelModules = [
|
kernelModules = [
|
||||||
|
@ -102,10 +100,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Change I/O scheduler to Kyber to try and reduce stuttering under load.
|
# Change I/O scheduler to BFQ to try and reduce stuttering under load.
|
||||||
# NVME supports `mq-deadline` and `kyber` schedulers
|
|
||||||
services.udev.extraRules = ''
|
services.udev.extraRules = ''
|
||||||
ACTION=="add|change", KERNEL=="nvme0n1", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber"
|
ACTION=="add|change", KERNEL=="nvme0*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
hardware = {
|
hardware = {
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
zellij # Terminal multiplexer
|
zellij # Terminal multiplexer
|
||||||
];
|
];
|
||||||
|
|
||||||
# Install the nos helper script
|
|
||||||
aux.system.nixos-upgrade-script.enable = true;
|
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: _prev: {
|
(final: _prev: {
|
||||||
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
||||||
|
|
|
@ -57,10 +57,16 @@ in
|
||||||
forgejo = {
|
forgejo = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings.server = {
|
settings.server = {
|
||||||
DOMAIN = pkgs.util.getDomainFromURL cfg.url;
|
DOMAIN =
|
||||||
|
let
|
||||||
|
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||||
|
in
|
||||||
|
builtins.concatStringsSep "." [
|
||||||
|
(builtins.elemAt parsedURL 1)
|
||||||
|
(builtins.elemAt parsedURL 2)
|
||||||
|
];
|
||||||
ROOT_URL = cfg.url;
|
ROOT_URL = cfg.url;
|
||||||
HTTP_PORT = 3000;
|
HTTP_PORT = 3000;
|
||||||
REPO_INDEXER_ENABLED = true; # Enable code indexing
|
|
||||||
};
|
};
|
||||||
useWizard = true;
|
useWizard = true;
|
||||||
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
||||||
|
|
|
@ -23,7 +23,17 @@ in
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "monthly";
|
default = "monthly";
|
||||||
};
|
};
|
||||||
nixos-upgrade-script.enable = lib.mkEnableOption "Installs the nos (nixos-upgrade-script) helper script.";
|
nixos-upgrade-script = {
|
||||||
|
enable = lib.mkEnableOption "Installs the nos (nixos-upgrade-script) helper script.";
|
||||||
|
configDir = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Path to your NixOS configuration files.";
|
||||||
|
};
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "The user to run the upgrade script as.";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -90,7 +90,6 @@ in
|
||||||
theme = "gentoo";
|
theme = "gentoo";
|
||||||
};
|
};
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
nos = lib.mkIf config.aux.system.nixos-upgrade-script.enable "nixos-upgrade-script";
|
|
||||||
z = "zellij";
|
z = "zellij";
|
||||||
update = "upgrade";
|
update = "upgrade";
|
||||||
upgrade = "nh os boot --update --ask";
|
upgrade = "nh os boot --update --ask";
|
||||||
|
|
Loading…
Reference in a new issue