Compare commits

...

2 commits

Author SHA1 Message Date
741b1e72bc
feat(darwin): enable distributedBuilds
All checks were successful
/ check (push) Successful in 5m9s
2024-09-20 08:58:18 +02:00
6778b8dac3
refactor: add modules 2024-09-20 08:57:36 +02:00
29 changed files with 223 additions and 156 deletions

View file

@ -404,7 +404,7 @@
"nur": "nur",
"pre-commit-hooks": "pre-commit-hooks",
"vscode-server": "vscode-server",
"wsl": "wsl"
"nixos-wsl": "nixos-wsl"
}
},
"rust-overlay": {
@ -488,7 +488,7 @@
"type": "github"
}
},
"wsl": {
"nixos-wsl": {
"inputs": {
"flake-compat": [],
"flake-utils": [

View file

@ -26,7 +26,7 @@
system = "x86_64-linux";
username = "winston";
isGraphical = false;
extraModules = [ inputs.wsl.nixosModules.default ];
extraModules = [ inputs.nixos-wsl.nixosModules.default ];
}
];
imports = [ inputs.pre-commit-hooks.flakeModule ];
@ -65,9 +65,6 @@
RULES = "./home/secrets/secrets.nix";
buildInputs =
(with pkgs; [
dhall
dhall-lsp-server
dhall-yaml
just
nix-output-monitor
nixd
@ -132,7 +129,7 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
wsl = {
nixos-wsl = {
url = "github:nix-community/nixos-wsl";
inputs.flake-compat.follows = "";
inputs.flake-utils.follows = "flake-utils";

View file

@ -1,6 +1,7 @@
{
config,
lib,
osConfig,
pkgs,
...
}:
@ -43,9 +44,10 @@ in
watchexec
]
++ lib.optionals (config.isGraphical && isLinux) [
_1password-gui
uhk-agent
(_1password-gui.override { polkitPolicyOwners = [ osConfig.dotfiles.username ]; })
neovide
nextcloud-client
uhk-agent
]
);
sessionVariables.SSH_AUTH_SOCK = lib.optionalString isDarwin "${config.programs.gpg.homedir}/S.gpg-agent.ssh";

View file

@ -6,6 +6,7 @@
}:
rec {
inherit (pkgs.stdenv) isLinux isDarwin;
inherit (pkgs.lib) mkDefault mkOption types;
extraSpecialArgs = {
flakePath =
@ -21,10 +22,10 @@ rec {
"/Users/${username}"
else
throw "Unsupported system";
home.username = username;
isGraphical = false;
targets.genericLinux.enable = isLinux;
xdg.mime.enable = isLinux;
home.username = mkDefault username;
isGraphical = mkDefault false;
targets.genericLinux.enable = mkDefault isLinux;
xdg.mime.enable = mkDefault isLinux;
};
modules =
@ -36,10 +37,7 @@ rec {
])
++ [
(
{ osConfig, lib, ... }:
let
inherit (lib) mkOption types;
in
{ osConfig, ... }:
{
options = {
isGraphical = mkOption {

View file

@ -1,5 +1,4 @@
{
config,
pkgs,
lib,
...
@ -66,6 +65,7 @@
builtins.concatStringsSep "\n" (map (app: ''yabai -m rule --add app="${app}" ${options}'') apps);
unmanaged = apps: mkRules apps "manage=off";
in
# bash
''
# auto-inject scripting additions
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
@ -119,6 +119,7 @@
)
);
in
# bash
''
#!/usr/bin/env sh
# focus window
@ -157,11 +158,9 @@
};
};
environment.systemPackages = [ pkgs.jankyborders ];
launchd.user.agents.jankyborders.serviceConfig = {
ProgramArguments = [ "${pkgs.jankyborders}/bin/borders" ];
ProgramArguments = [ (lib.getExe pkgs.jankyborders) ];
KeepAlive = true;
RunAtLoad = true;
EnvironmentVariables.PATH = "${pkgs.jankyborders}/bin:${config.environment.systemPath}";
};
}

View file

@ -15,9 +15,9 @@ let
);
binary =
{
swayfx = "sway";
hyprland = "Hyprland";
sway = "sway";
hyprland = "hypr";
swayfx = "sway";
}
.${desktop} or (throw "greetd: desktop not supported");
in
@ -25,7 +25,7 @@ in
config = lib.mkIf condition {
services.greetd = {
enable = true;
settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --cmd '${pkgs.dbus}/bin/dbus-run-session ${binary}'";
settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --remember --cmd ${binary}";
};
services.gnome.gnome-keyring.enable = true;
security.pam.services.greetd = {

View file

@ -37,12 +37,13 @@ in
programs.sway = {
enable = true;
package = lib.mkIf (config.dotfiles.desktop == "swayfx") pkgs.swayfx;
package = if (config.dotfiles.desktop == "swayfx") then pkgs.swayfx else pkgs.sway;
extraPackages = with pkgs; [
swaylock-effects
swayidle
];
extraSessionCommands = ''
extraSessionCommands = # bash
''
# session
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway

View file

@ -1,18 +0,0 @@
{ lib, pkgs, ... }:
let
inherit (lib) mkForce;
in
{
services = {
kanata.enable = mkForce false;
dnsmasq.enable = mkForce false;
mullvad-vpn.enable = mkForce false;
stubby.enable = mkForce false;
};
virtualisation.podman.enable = mkForce false;
system = {
build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true";
stateVersion = "23.11";
};
}

View file

@ -2,7 +2,10 @@
{
imports = [ ./hardware.nix ];
dotfiles.desktop = "sway";
dotfiles = {
desktop = "sway";
gaming.enable = true;
};
networking = {
networkmanager.enable = true;
@ -17,54 +20,31 @@
time.timeZone = "Europe/Vienna";
services = {
flatpak.enable = true;
openssh.enable = true;
pcscd.enable = true;
transmission.enable = true;
transmission.openFirewall = true;
};
virtualisation.podman.enable = true;
virtualisation.libvirtd.enable = true;
virtualisation = {
libvirtd.enable = true;
podman.enable = true;
};
users.users."${config.dotfiles.username}".extraGroups = [
"libvirtd"
"transmission"
];
environment.systemPackages = with pkgs; [
cabextract
discover-overlay
lutris-free
mangohud
(pkgs.wrapOBS {
plugins = with pkgs.obs-studio-plugins; [
obs-backgroundremoval
obs-composite-blur
obs-pipewire-audio-capture
wlrobs
];
})
virt-manager
wineWowPackages.staging
winetricks
virtiofsd
];
programs = {
gamemode = {
enable = true;
settings = {
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
steam = {
enable = true;
package = pkgs.steam.override {
extraEnv.MANGOHUD = 1;
extraPkgs =
p: with p; [
corefonts
protontricks
gamescope
];
};
};
};
system.stateVersion = "22.11";
}

View file

@ -3,7 +3,7 @@ rec {
hmCommonConfig =
{ username }:
(
{ config, pkgs, ... }:
{ pkgs, ... }:
let
homeLib = import ../home/lib.nix { inherit inputs username pkgs; };
in
@ -34,6 +34,9 @@ rec {
extraModules ? [ ],
}:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
ldTernary =
l: d:
if pkgs.stdenv.isLinux then
@ -42,17 +45,16 @@ rec {
d
else
throw "Unsupported system";
target = ldTernary "nixosConfigurations" "darwinConfigurations";
builder = ldTernary inputs.nixpkgs.lib.nixosSystem inputs.darwin.lib.darwinSystem;
hostPlatform = ldTernary "nixos" "darwin";
module = ldTernary "nixosModules" "darwinModules";
hostPlatform = ldTernary "linux" "darwin";
target = ldTernary "nixosConfigurations" "darwinConfigurations";
linuxModules = [ inputs.nixos-cosmic.nixosModules.default ];
darwinModules = [ inputs.nekowinston-nur.darwinModules.default ];
pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
inherit (pkgs.lib) mkOption types;
linuxModules = [
inputs.nixos-cosmic.nixosModules.default
inputs.nixos-wsl.nixosModules.default
];
in
{
${target}."${host}" = builder {
@ -60,43 +62,25 @@ rec {
modules =
[
{
options = {
config = {
dotfiles = {
username = mkOption {
type = types.str;
default = username;
description = "The username of the user";
username = lib.mkDefault username;
desktop = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null;
};
desktop = mkOption {
type = types.nullOr (
types.enum [
"cosmic"
"gnome"
"hyprland"
"sway"
"swayfx"
]
);
default = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null;
description = "The desktop environment to use";
isGraphical = lib.mkDefault isGraphical;
networking.hostName = lib.mkDefault host;
};
};
isGraphical = mkOption {
type = types.bool;
default = isGraphical;
description = "Whether the system is a graphical target";
};
};
config.networking.hostName = host;
}
../modules/shared
../modules/${hostPlatform}
./common/shared
./common/${hostPlatform}
./${host}
inputs.home-manager.${module}.home-manager
(hmCommonConfig { inherit username; })
]
++ lib.optionals pkgs.stdenv.isLinux linuxModules
++ lib.optionals pkgs.stdenv.isDarwin darwinModules
++ lib.optionals pkgs.stdenv.isLinux linuxModules
++ extraModules;
specialArgs = {
inherit inputs;

View file

@ -11,7 +11,9 @@
longitude = 16.363449;
};
nix.buildMachines = [
nix = {
distributedBuilds = true;
buildMachines = [
{
hostName = "orb";
sshUser = "nixos";
@ -28,4 +30,5 @@
];
}
];
};
}

View file

@ -1,5 +1,5 @@
{
imports = [ ../common/wsl ];
dotfiles.wsl.enable = true;
i18n.defaultLocale = "en_US.UTF-8";
location = {
@ -8,10 +8,5 @@
};
time.timeZone = "Europe/Vienna";
wsl = {
enable = true;
defaultUser = "winston";
startMenuLaunchers = true;
useWindowsDriver = true;
};
system.stateVersion = "23.11";
}

View file

@ -0,0 +1 @@
{ }

View file

@ -0,0 +1,6 @@
{
imports = [
./gaming.nix
./wsl.nix
];
}

41
modules/nixos/gaming.nix Normal file
View file

@ -0,0 +1,41 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.dotfiles.gaming;
gamePkgs =
pkgs: with pkgs; [
corefonts
gamescope
mangohud
];
in
{
options.dotfiles.gaming.enable = lib.mkEnableOption "gaming configuration";
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
discover-overlay
(lutris.override { extraPkgs = gamePkgs; })
];
programs = {
gamemode = {
enable = true;
settings = {
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
steam = {
enable = true;
package = pkgs.steam.override { extraPkgs = gamePkgs; };
};
};
};
}

37
modules/nixos/wsl.nix Normal file
View file

@ -0,0 +1,37 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.dotfiles.wsl;
inherit (lib) mkDefault mkForce;
in
{
options.dotfiles.wsl.enable = lib.mkEnableOption "NixOS-WSL specific options";
config = lib.mkIf cfg.enable {
# disable services that are not needed in WSL
services = {
dnsmasq.enable = mkForce false;
kanata.enable = mkForce false;
mullvad-vpn.enable = mkForce false;
stubby.enable = mkForce false;
};
# podman runs on native Windows
virtualisation.podman.enable = mkForce false;
# main WSL defaults
wsl = {
enable = mkDefault true;
defaultUser = mkDefault config.dotfiles.username;
startMenuLaunchers = mkDefault true;
useWindowsDriver = mkDefault true;
};
# skip installing the bootloader
system.build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true";
};
}

36
modules/shared/config.nix Normal file
View file

@ -0,0 +1,36 @@
{
lib,
...
}:
let
inherit (lib) types;
in
{
options = {
dotfiles = lib.mkOption {
type = types.submodule {
options = {
desktop = lib.mkOption {
description = "The desktop environment to use";
type = types.nullOr (
types.enum [
"cosmic"
"gnome"
"hyprland"
"sway"
"swayfx"
]
);
};
username = lib.mkOption {
description = "The username of the user";
type = types.str;
};
};
};
};
isGraphical = lib.mkEnableOption "" // {
description = "Whether the system is a graphical target";
};
};
}

View file

@ -0,0 +1,5 @@
{
imports = [
./config.nix
];
}

View file

@ -4,15 +4,15 @@
(
final: prev:
let
srcs = prev.callPackages ../_sources/generated.nix { };
srcs = final.callPackages ../_sources/generated.nix { };
in
{
nushellPlugins = (prev.nushellPlugins or { }) // {
clipboard = prev.callPackage ./nu_plugin_clipboard.nix { };
clipboard = final.callPackage ./nu_plugin_clipboard.nix { };
};
starship = prev.starship.overrideAttrs (old: {
patches = [
(prev.fetchpatch {
(final.fetchpatch {
url = "https://github.com/starship/starship/pull/4439.patch";
sha256 = "sha256-BKH3elz96Oa424Oz5UIKA2/BOpkym1LTestvccFinnc=";
})
@ -22,10 +22,10 @@
inherit (srcs.yabai) version src;
});
nur = import inputs.nur {
nurpkgs = prev;
pkgs = prev;
nurpkgs = final;
pkgs = final;
repoOverrides = {
nekowinston = inputs.nekowinston-nur.packages.${prev.stdenv.system};
nekowinston = inputs.nekowinston-nur.packages.${final.stdenv.system};
};
};
}