Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging: 2024-11-14 #20

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Exhaustive Flake Test

on:
workflow_dispatch:
push:
branches:
- staging

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2

- name: Free Disk Space
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true

- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
allow-import-from-derivation = false
eval-cache = false

- name: Run Flake Check
run: nix flake check

- name: Build NixOS Configurations
run: |
nix build '.#nixosConfigurations.LAPTOP-3DT4F02.config.system.build.toplevel'
nix build '.#nixosConfigurations.DESKTOP-3DT4F02.config.system.build.toplevel'
nix build '.#nixosConfigurations.ISO-3DT4F02.config.system.build.isoImage'
2 changes: 2 additions & 0 deletions hosts/laptop/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
}:
{
imports = [
./hardware
./mounts.nix
./time-sync.nix
];

config = {
Expand Down
5 changes: 5 additions & 0 deletions hosts/laptop/hardware/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
imports = [
./power-savings.nix
];
}
32 changes: 32 additions & 0 deletions hosts/laptop/hardware/power-savings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
...
}:
{
config = {
boot.blacklistedKernelModules = [
"btusb"
"bluetooth"
"snd_hda_codec_hdmi"
];

boot.kernelParams = [
"pcie_aspm.policy=powersupersave"
];

powerManagement.enable = true;
powerManagement.scsiLinkPolicy = "med_power_with_dipm";

# TODO: /sys/devices/system/cpu/cpu*/power/energy_perf_bias -> 8/15

boot.kernel.sysctl = {
"kernel.nmi_watchdog" = 0;
};

services.tlp.enable = false;

services = {
auto-cpufreq.enable = true;
thermald.enable = true;
};
};
}
12 changes: 12 additions & 0 deletions hosts/laptop/time-sync.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
config,
...
}:
{
config = {
services.chrony.enable = true;
my.persist.directories = [
config.services.chrony.directory
];
};
}
3 changes: 1 addition & 2 deletions modules/nixos/programs/nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ in {

# Wrap the official nix binary with a snippet to allow
# rapid repl access to `pkgs.*` and `lib.*` attributes.
#nix.package = pkgs.callPackage ./package.nix { nix = pkgs.lix; };
nix.package = pkgs.lix;
nix.package = pkgs.callPackage ./package.nix { nix = pkgs.lix; };
}
{
# Throttle the nix-daemon so it doesn't consume
Expand Down
46 changes: 12 additions & 34 deletions modules/nixos/programs/nix/package.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
{
lib,
runCommandLocal,
writeShellScriptBin,
callPackage,
buildEnv,

nix,
}:
let
nix-wrapped = writeShellScriptBin "nix" ''
declare -a args

if [ "$1" = "repl" ]; then
# https://wiki.nixos.org/wiki/Flakes#Getting_Instant_System_Flakes_Repl
args+=(repl --expr "builtins // { inherit (import <nixpkgs> { config.allowUnfree = true; }) pkgs lib; }")
shift 1
fi
wrapper = callPackage ./wrapper { inherit nix; };
in buildEnv {
inherit (nix) name;

# https://discourse.nixos.org/t/how-do-nix-legacy-commands-work-when-they-are-just-symbolic-links-to-nix/52797
cmd=(
"$(basename $0)"
"''${args[@]}"
"$@"
)

PATH="${nix}/bin:$PATH" exec "''${cmd[@]}"
'';
in runCommandLocal "wrap-nix" {
pname = lib.getName nix;
version = lib.getVersion nix;

outputs = nix.outputs;
paths = [
wrapper
nix
];

ignoreCollisions = true;
extraOutputsToInstall = nix.meta.outputsToInstall;
meta.mainProgram = "nix";
} ''
install -Dm755 -t $out/bin ${lib.getExe nix-wrapped}

${lib.concatStringsSep "\n" (map (output: ''
mkdir -p ${placeholder output}
cp --update=none -rt ${placeholder output} ${nix.${output}}/*
''
) nix.outputs)}
''
}
39 changes: 39 additions & 0 deletions modules/nixos/programs/nix/wrapper/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
lib,
stdenvNoCC,

nix,
}:
stdenvNoCC.mkDerivation {
inherit (nix) name;

src = with lib.fileset; toSource {
root = ./.;
fileset = unions [
./nix.sh
];
};

installPhase = ''
runHook preInstall

install -Dm755 nix.sh $out/bin/nix

runHook postInstall
'';

postInstall = ''
substituteInPlace $out/bin/nix \
--subst-var-by nix ${lib.getExe nix}
'';

meta = with lib; {
description = "Very bare-bones wrapper around the Nix CLI";

license = licenses.free;
maintainers = with maintainers; [ frontear ];
platforms = platforms.linux;

mainProgram = "nix";
};
}
25 changes: 25 additions & 0 deletions modules/nixos/programs/nix/wrapper/nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

origArgs=("$@")
newArgs=()

for i in "${!origArgs[@]}"; do
newArgs+=("${origArgs[$i]}")

if [ $i -eq 0 ]; then
case "${origArgs[0]}" in
repl)
newArgs+=("--expr" "builtins // { inherit (import <nixpkgs> { config.allowUnfree = true; }) pkgs lib; }")
;;
esac
fi
done

# The official Nix binary resolves nix-legacy binary calls through
# disambiguating $0. This means we must set it directly here in the
# exec call in order to help it out.
exec -a "$0" "@nix@" "${newArgs[@]}"
10 changes: 10 additions & 0 deletions users/frontear/home/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
basedpyright
clang-tools
nixd
rust-analyzer
zls
];

plugins = with pkgs.vimPlugins; [
Expand Down Expand Up @@ -103,6 +105,14 @@
lspconfig.nixd.setup({
capabilities = capabilities,
})

lspconfig.rust_analyzer.setup({
capabilities = capabilities,
})

lspconfig.zls.setup({
capabilities = capabilities,
})
'';
}
{
Expand Down
4 changes: 2 additions & 2 deletions users/frontear/home/sway/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ bindsym --locked {
XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_SINK@ 5%-
XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_SINK@ 5%+ --limit 1.0

XF86MonBrightnessUp exec light -A 10
XF86MonBrightnessDown exec light -U 10
XF86MonBrightnessUp exec xbacklight -inc 10
XF86MonBrightnessDown exec xbacklight -dec 10
}

bindsym --no-repeat {
Expand Down
2 changes: 1 addition & 1 deletion users/frontear/nixos/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
config.programs.ydotool.group
];

programs.light.enable = true;
hardware.acpilight.enable = true;
programs.ydotool.enable = true;
};
}