Compare commits
No commits in common. "865bffa641925c559f31ef293efe42ff11be9062" and "7b9d9053bff3daec81e2afebbb4f089341abb368" have entirely different histories.
865bffa641
...
7b9d9053bf
|
@ -17,13 +17,8 @@ let
|
|||
in
|
||||
{
|
||||
config = {
|
||||
boot = {
|
||||
# From nixos-generate-config
|
||||
initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "sd_mod" "rtsx_usb_sdmmc" ];
|
||||
kernelModules = [ "kvm-intel" ];
|
||||
|
||||
# UEFI works here, and variables can be touched
|
||||
loader = {
|
||||
boot.loader = {
|
||||
efi.canTouchEfiVariables = lib.mkDefault true;
|
||||
grub = {
|
||||
enable = true;
|
||||
|
@ -32,11 +27,7 @@ in
|
|||
# TODO Maybe we could? In case the HDD doesn't boot anymore?
|
||||
};
|
||||
};
|
||||
};
|
||||
# Also from nixos-generate-config
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
# TODO Do we really need that? Besides maybe microcode?
|
||||
|
||||
hardware.cpu.intel.updateMicrocode = true;
|
||||
frogeye.desktop = {
|
||||
x11_screens = [
|
||||
displays.deskLeft.output
|
||||
|
@ -44,23 +35,11 @@ in
|
|||
];
|
||||
maxVideoHeight = 1440;
|
||||
numlock = true;
|
||||
phasesCommands = {
|
||||
jour = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 40000 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 20 -d 1 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 20 -d 2 &
|
||||
'';
|
||||
crepuscule = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 10000 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 10 -d 1 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 10 -d 2 &
|
||||
'';
|
||||
nuit = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 1 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 0 -d 1 &
|
||||
${pkgs.ddcutil}/bin/ddcutil setvcp 10 0 -d 2 &
|
||||
'';
|
||||
# TODO Display 2 doesn't work anymore?
|
||||
phasesBrightness = {
|
||||
enable = true;
|
||||
jour = "40000";
|
||||
crepuscule = "10000";
|
||||
nuit = "1";
|
||||
};
|
||||
};
|
||||
nixpkgs.overlays = [
|
||||
|
|
17
flake.nix
17
flake.nix
|
@ -80,6 +80,10 @@
|
|||
type = "app";
|
||||
program = "${disko.packages.${system}.default}/bin/disko";
|
||||
};
|
||||
nixos-generate-config = {
|
||||
type = "app";
|
||||
program = "${pkgs.nixos-install-tools}/bin/nixos-generate-config";
|
||||
};
|
||||
nixos-install = {
|
||||
type = "app";
|
||||
program = "${pkgs.nixos-install-tools}/bin/nixos-install";
|
||||
|
@ -94,19 +98,6 @@
|
|||
${pkgs.lix}/bin/nix repl --expr 'let flake = builtins.getFlake "${self}"; in flake // flake.nixosConfigurations // rec { pkgs = import ${nixpkgs} {}; lib = pkgs.lib; }'
|
||||
''}";
|
||||
};
|
||||
updateLocalFlakes = {
|
||||
type = "app";
|
||||
program = "${pkgs.writers.writePython3 "update-local-flakes" { }
|
||||
(builtins.readFile ./common/update-local-flakes.py)}";
|
||||
};
|
||||
nixosRebuild = {
|
||||
type = "app";
|
||||
program = "${pkgs.writeShellScript "rebuild" ''${pkgs.writeShellApplication {
|
||||
name = "rebuild";
|
||||
runtimeInputs = with pkgs; [ nix-output-monitor nixos-rebuild ];
|
||||
text = builtins.readFile ./os/rebuild.sh;
|
||||
}}/bin/rebuild ${self} "$@"''}";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -2,23 +2,31 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
phases = [
|
||||
{ command = "jour"; specialisation = null; }
|
||||
{ command = "crepuscule"; specialisation = "dark"; }
|
||||
{ command = "nuit"; specialisation = "dark"; }
|
||||
{ command = "jour"; polarity = "light"; }
|
||||
{ command = "crepuscule"; polarity = "dark"; }
|
||||
{ command = "nuit"; polarity = "dark"; }
|
||||
];
|
||||
phasesBrightness = config.frogeye.desktop.phasesBrightness;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
home.packages = map
|
||||
(phase: (pkgs.writeShellScriptBin phase.command ''
|
||||
switch="/nix/var/nix/profiles/system${lib.strings.optionalString (phase.specialisation != null) "/specialisation/${phase.specialisation}"}/bin/switch-to-configuration"
|
||||
(phase: (pkgs.writeShellApplication {
|
||||
name = "${phase.command}";
|
||||
runtimeInputs = [ pkgs.brightnessctl ];
|
||||
text = (lib.optionalString phasesBrightness.enable ''
|
||||
brightnessctl set ${builtins.getAttr phase.command phasesBrightness}
|
||||
'') + ''
|
||||
switch="/nix/var/nix/profiles/system/specialisation/${phase.polarity}/bin/switch-to-configuration"
|
||||
if [ -x "$switch" ]
|
||||
then
|
||||
sudo "$switch" test &
|
||||
sudo "$switch" boot &
|
||||
# In two steps to get the visual changes slightly earlier
|
||||
sudo "$switch" test
|
||||
sudo "$switch" boot
|
||||
fi
|
||||
${builtins.getAttr phase.command config.frogeye.desktop.phasesCommands}
|
||||
''))
|
||||
'';
|
||||
})
|
||||
)
|
||||
phases;
|
||||
xsession.windowManager.i3.config.keybindings = {
|
||||
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
{ pkgs, config, ... }:
|
||||
let
|
||||
ulf = pkgs.writers.writePython3 "update-local-flakes" {
|
||||
} (builtins.readFile ./update-local-flakes.py);
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
|
@ -10,26 +14,32 @@
|
|||
verb="$1"
|
||||
shift
|
||||
fi
|
||||
nixos_flake="$(readlink -f /etc/nixos)"
|
||||
if [ -f "$nixos_flake/flake.nix" ]
|
||||
nixos_flake="/etc/nixos/flake.nix"
|
||||
if [ -f "$nixos_flake" ]
|
||||
then
|
||||
nix run "$nixos_flake#updateLocalFlakes" -- "$nixos_flake"
|
||||
nix run "$nixos_flake#nixosRebuild" -- "$verb" "$@"
|
||||
sudo ${ulf} "$nixos_flake"
|
||||
# ${pkgs.nix-output-monitor}/bin/nom build "$(dirname "$nixos_flake")#nixosConfigurations.$HOSTNAME.config.system.build.toplevel"
|
||||
if [ "$verb" = "switch" ] || [ "$verb" = "test" ]
|
||||
then
|
||||
sudo nixos-rebuild "$verb" --specialisation ${config.frogeye.polarity} "$@"
|
||||
else
|
||||
sudo nixos-rebuild "$verb" "$@"
|
||||
fi
|
||||
fi
|
||||
hm_flake="${config.xdg.configHome}/home-manager/flake.nix"
|
||||
if [ -f "$hm_flake" ]
|
||||
then
|
||||
${ulf} "$hm_flake"
|
||||
home-manager "$verb" "$@"
|
||||
fi
|
||||
nod_flake="${config.xdg.configHome}/nix-on-droid/flake.nix"
|
||||
if [ -f "$nod_flake" ]
|
||||
then
|
||||
${ulf} "$nod_flake"
|
||||
nix-on-droid "$verb" --flake "$(dirname "$nod_flake")" "$@"
|
||||
fi
|
||||
# TODO Fix nix-on-droid and home-manager
|
||||
# hm_flake="${config.xdg.configHome}/home-manager/flake.nix"
|
||||
# if [ -f "$hm_flake" ]
|
||||
# then
|
||||
# {ulf} "$hm_flake"
|
||||
# home-manager "$verb" "$@"
|
||||
# fi
|
||||
# nod_flake="${config.xdg.configHome}/nix-on-droid/flake.nix"
|
||||
# if [ -f "$nod_flake" ]
|
||||
# then
|
||||
# {ulf} "$nod_flake"
|
||||
# nix-on-droid "$verb" --flake "$(dirname "$nod_flake")" "$@"
|
||||
# fi
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
# TODO make it a flake application, optional nom (is slow), test then boot, flags to confirm each, nvd diff here
|
||||
|
|
|
@ -12,14 +12,13 @@ GET_INPUTS_CMD = [
|
|||
]
|
||||
|
||||
|
||||
def process_flake(flakeUri: str) -> None:
|
||||
def process_flake(flake: str) -> None:
|
||||
# get full path
|
||||
flakeUri = os.path.normpath(flakeUri)
|
||||
flakeFile = os.path.join(flakeUri, "flake.nix")
|
||||
if not os.path.isfile(flakeFile):
|
||||
raise FileNotFoundError(f"Flake not found: {flakeUri}")
|
||||
if not os.path.isfile(flake):
|
||||
raise FileNotFoundError(f"Flake not found: {flake}")
|
||||
dir = os.path.dirname(flake)
|
||||
# import dependencies
|
||||
p = subprocess.run(GET_INPUTS_CMD, cwd=flakeUri, stdout=subprocess.PIPE)
|
||||
p = subprocess.run(GET_INPUTS_CMD, cwd=dir, stdout=subprocess.PIPE)
|
||||
deps = json.loads(p.stdout)
|
||||
p.check_returncode()
|
||||
# for each dependency
|
||||
|
@ -35,8 +34,11 @@ def process_flake(flakeUri: str) -> None:
|
|||
# get flake file corresponding
|
||||
dep_path = dep_url.split(":")[1]
|
||||
if not dep_path.startswith("/"):
|
||||
dep_path = os.path.join(flakeUri, dep_path)
|
||||
process_flake(dep_path)
|
||||
dep_path = os.path.join(dir, dep_path)
|
||||
dep_path = os.path.normpath(dep_path)
|
||||
dep_flake = os.path.join(dep_path, "flake.nix")
|
||||
# call this function with the flake file
|
||||
process_flake(dep_flake)
|
||||
# update lockfile
|
||||
cmd = [
|
||||
"nix",
|
||||
|
@ -48,7 +50,7 @@ def process_flake(flakeUri: str) -> None:
|
|||
"update",
|
||||
dep_name,
|
||||
]
|
||||
p = subprocess.run(cmd, cwd=flakeUri)
|
||||
p = subprocess.run(cmd, cwd=dir)
|
||||
p.check_returncode()
|
||||
|
||||
|
||||
|
@ -57,6 +59,6 @@ if __name__ == "__main__":
|
|||
description="Recursively update lockfiles "
|
||||
"of flakes located on the system"
|
||||
)
|
||||
parser.add_argument("flake", help="Starting flake", default="/")
|
||||
parser.add_argument("flake", help="Starting flake", default="flake.nix")
|
||||
args = parser.parse_args()
|
||||
process_flake(args.flake)
|
|
@ -82,9 +82,24 @@ sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#d
|
|||
trap - ERR
|
||||
rm "$luks_pass_file"
|
||||
|
||||
# Save that system configuration uses this repo
|
||||
sudo mkdir -p "${mountpoint}/etc"
|
||||
sudo ln -sfn "${flake_uri}" "${mountpoint}/nixos"
|
||||
# Generate hardware-config.nix
|
||||
sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#nixos-generate-config" -- --no-filesystems --root "$mountpoint"
|
||||
# --no-filesystems because they are imported via disko
|
||||
sudo rm "$mountpoint/etc/nixos/configuration.nix"
|
||||
|
||||
# Plug system configuration into this git repo
|
||||
sudo mkdir -p "${mountpoint}/etc/nixos"
|
||||
echo "{
|
||||
description = \"$name system config\";
|
||||
inputs.entrypoint.url = \"git+file:$flake_uri\";
|
||||
outputs = { self, entrypoint, ... }:
|
||||
{
|
||||
nixosConfigurations.$name = entrypoint.nixosConfigurations.$name.extendModules {
|
||||
modules = [ ./hardware-configuration.nix ];
|
||||
};
|
||||
};
|
||||
}" | sudo tee "${mountpoint}/etc/nixos/flake.nix" > /dev/null
|
||||
# Everything there should be covered by (and conflicts with) the repo anyways.
|
||||
|
||||
# Install NixOS! Or create a new generation.
|
||||
sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#nixos-install" -- --no-root-password --root "$mountpoint" --flake "${mountpoint}/etc/nixos#${name}"
|
||||
|
|
|
@ -22,10 +22,11 @@
|
|||
description = "Maximum video height in pixel the machine can reasonably watch";
|
||||
default = 1080;
|
||||
};
|
||||
phasesCommands = {
|
||||
jour = lib.mkOption { type = lib.types.lines; default = ""; description = "Command to execute for phase: jour"; };
|
||||
crepuscule = lib.mkOption { type = lib.types.lines; default = ""; description = "Command to execute for phase: crepuscule"; };
|
||||
nuit = lib.mkOption { type = lib.types.lines; default = ""; description = "Command to execute for phase: nuit"; };
|
||||
phasesBrightness = {
|
||||
enable = lib.mkEnableOption "Set a specific brightness for the screen when running phases commands";
|
||||
jour = lib.mkOption { type = lib.types.str; default = "100%"; description = "brightnessctl value for phase: jour"; };
|
||||
crepuscule = lib.mkOption { type = lib.types.str; default = "50%"; description = "brightnessctl value for phase: crepuscule"; };
|
||||
nuit = lib.mkOption { type = lib.types.str; default = "1%"; description = "brightnessctl value for phase: nuit"; };
|
||||
};
|
||||
};
|
||||
dev = {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
./common.nix
|
||||
./desktop
|
||||
./dev
|
||||
./diff
|
||||
disko.nixosModules.disko
|
||||
./gaming
|
||||
./geoffrey.nix
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||
boot.kernelModules = [ "i2c-dev" ]; # Allows using ddcutil
|
||||
services = {
|
||||
blueman.enable = true;
|
||||
displayManager.defaultSession = "none+i3";
|
||||
udev.packages = with pkgs; [ ddcutil ]; # TODO Doesn't seem to help
|
||||
xserver = {
|
||||
enable = true;
|
||||
windowManager.i3.enable = true;
|
||||
|
|
14
os/diff/default.nix
Normal file
14
os/diff/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
config = {
|
||||
system.activationScripts.diff = {
|
||||
supportsDryActivation = true;
|
||||
text = ''
|
||||
if [ -h /run/current-system ]
|
||||
then
|
||||
${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
specialisation = {
|
||||
dark.configuration.frogeye.polarity = "dark";
|
||||
light.configuration.frogeye.polarity = "light";
|
||||
};
|
||||
|
||||
# Fix https://nix-community.github.io/home-manager/index.html#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
# Handle arguments
|
||||
self="$1"
|
||||
verb="$2"
|
||||
shift
|
||||
shift
|
||||
|
||||
if [ "$verb" != "build" ] && [ "$verb" != "test" ] && [ "$verb" != "boot" ] && [ "$verb" != "switch" ] && [ "$verb" != "confirm" ]
|
||||
then
|
||||
echo "Action should be one of: build, test, boot, switch, confirm"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Build, looking nice
|
||||
tmpdir="$(mktemp -d)"
|
||||
# sudo so the eval cache is shared with nixos-rebuild
|
||||
sudo nom build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" -o "$tmpdir/toplevel" "$@"
|
||||
toplevel="$(readlink "$tmpdir/toplevel")"
|
||||
rm -rf "$tmpdir"
|
||||
|
||||
# Show diff
|
||||
nvd diff /nix/var/nix/profiles/system "$toplevel"
|
||||
|
||||
# Figure out specialisation
|
||||
specialisationArgs=""
|
||||
currentSystem="$(readlink /run/current-system)"
|
||||
while read -r specialisation
|
||||
do
|
||||
if [ "$(readlink "/nix/var/nix/profiles/system/specialisation/$specialisation")" = "$currentSystem" ]
|
||||
then
|
||||
specialisationArgs=("--specialisation" "$specialisation")
|
||||
fi
|
||||
done <<< "$(ls /nix/var/nix/profiles/system/specialisation)"
|
||||
|
||||
# Apply
|
||||
if [ "$verb" = "confirm" ]
|
||||
then
|
||||
echo "Apply configuration? [y/N]"
|
||||
read -r confirm
|
||||
fi
|
||||
if [ "$verb" = "test" ] || [ "$verb" = "switch" ] || [ "$confirm" = "y" ]
|
||||
then
|
||||
sudo nixos-rebuild --flake "$self#$HOSTNAME" test "${specialisationArgs[@]}" "$@"
|
||||
fi
|
||||
|
||||
# Set as boot
|
||||
if [ "$verb" = "confirm" ]
|
||||
then
|
||||
echo "Set configuration as boot? [y/N]"
|
||||
read -r confirm
|
||||
fi
|
||||
if [ "$verb" = "boot" ] || [ "$verb" = "switch" ] || [ "$confirm" = "y" ]
|
||||
then
|
||||
sudo nixos-rebuild --flake "$self#$HOSTNAME" boot "$@"
|
||||
fi
|
|
@ -16,16 +16,11 @@
|
|||
frogeye.desktop = {
|
||||
x11_screens = [ "DP-1" "eDP-1" ];
|
||||
maxVideoHeight = 1080;
|
||||
phasesCommands = {
|
||||
jour = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 3500
|
||||
'';
|
||||
crepuscule = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 3000
|
||||
'';
|
||||
nuit = ''
|
||||
${pkgs.brightnessctl}/bin/brightnessctl set 700
|
||||
'';
|
||||
phasesBrightness = {
|
||||
enable = true;
|
||||
jour = "3500";
|
||||
crepuscule = "3000";
|
||||
nuit = "700";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue