flake root cleanup

This commit is contained in:
Daniel Flanagan 2024-06-28 09:51:25 -05:00
parent f87fbad500
commit a783f6c146
8 changed files with 297 additions and 284 deletions

230
flake.nix
View file

@ -11,8 +11,8 @@
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.inputs.nixpkgs-stable.follows = "nixpkgs";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
@ -26,29 +26,51 @@
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
disko,
# sops-nix,
pre-commit,
home-manager,
helix,
hardware,
pre-commit-hooks,
hyprland,
slippi,
...
} @ inputs: let
}: let
inherit (self) outputs;
# TODO: make @ inputs unnecessary by making arguments explicit in all modules?
systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"];
forSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: import nixpkgs {inherit system;};
genPkgs = f: (f (forSystems pkgsFor));
in {
colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire;
# colors = (import ./lib/colors.nix inputs).color-schemes.donokai;
pkgsFor = system: (import nixpkgs {
inherit system;
inherit (outputs) overlays;
});
genPkgs = func: (forSystems (system: func (pkgsFor system)));
pkg = callee: overrides: genPkgs (pkgs: pkgs.callPackage callee overrides);
vanillaPkg = callee: pkg callee {};
font = {
name = "IosevkaLyteTerm";
size = 12;
# colors = (pkg ./lib/colors.nix {}).schemes.catppuccin-mocha-sapphire;
# font = {
# name = "IosevkaLyteTerm";
# size = 12;
# };
moduleArgs = {
# inherit colors font;
inherit helix slippi hyprland hardware disko home-manager;
inherit (outputs) nixosModules homeManagerModules diskoConfigurations overlays;
};
in {
diskoConfigurations = import ./disko;
templates = import ./templates;
packages = vanillaPkg ./packages;
packages = genPkgs (pkgs: import ./packages {inherit pkgs;});
formatter = genPkgs (pkgs: pkgs.alejandra);
checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
formatter = genPkgs (p: p.alejandra);
checks = vanillaPkg ({system}: {
pre-commit-check = pre-commit.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
@ -56,109 +78,97 @@
};
});
devShell = genPkgs (pkgs:
pkgs.mkShell {
inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
devShells = vanillaPkg ({
system,
pkgs,
mkShell,
}: {
default = mkShell {
inherit (outputs.checks.${system}.pre-commit-check) shellHook;
buildInputs = with pkgs; [
lua-language-server
nodePackages.bash-language-server
];
});
};
});
overlays = {
additions = _final: prev: outputs.packages.${prev.system};
modifications = final: prev: {
final.helix = helix.outputs.packages.${final.system}.helix;
};
unstable-packages = final: _prev: {
final.unstable = import nixpkgs-unstable {
system = final.system;
config.allowUnfree = true;
};
};
};
overlays = import ./overlays {inherit nixpkgs;};
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
nixosConfigurations =
(builtins.mapAttrs (name: {
system,
modules,
...
}:
# let
# commonModules =
# in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
# TODO: avoid special args and actually pass inputs to modules?
inherit (self) outputs;
inherit inputs hardware;
};
# extraSpecialArgs = {
# inherit inputs outputs system;
# };
modules =
[
self.nixosModules.common
]
++ modules;
}) (import ./nixos))
// {
beefcake = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit (self) outputs;
inherit inputs hardware;
};
modules = [self.nixosModules.common ./nixos/beefcake.nix];
};
# rascal = {
# system = "x86_64-linux";
# modules = [./rascal.nix];
# };
# router = {
# system = "x86_64-linux";
# modules = [./router.nix];
# };
};
# nixosConfigurations =
# (builtins.mapAttrs (name: {
# system,
# modules,
# ...
# }:
# nixpkgs.lib.nixosSystem {
# inherit system;
# # specialArgs = moduleArgs;
# modules =
# [
# self.nixosModules.common
# ]
# ++ modules;
# }) (import ./nixos))
# // {
# beefcake = nixpkgs.lib.nixosSystem {
# system = "x86_64-linux";
# specialArgs = moduleArgs;
# modules = [self.nixosModules.common ./nixos/beefcake.nix];
# };
# };
homeConfigurations = {
# TODO: non-system-specific home configurations?
"deck" = let
system = "x86_64-linux";
in
home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor system;
extraSpecialArgs = {
inherit (self) outputs;
inherit inputs system;
inherit (self.outputs) colors font;
};
modules = with self.outputs.homeManagerModules; [
common
{
home.homeDirectory = "/home/deck";
home.username = "deck";
home.stateVersion = "24.05";
}
linux
];
};
workm1 = let
system = "aarch64-darwin";
in
home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor system;
extraSpecialArgs = {
inherit (self) outputs;
inherit inputs system;
inherit (self.outputs) colors font;
};
modules = with self.outputs.homeManagerModules; [
common
{
home.homeDirectory = "/Users/daniel.flanagan";
home.username = "daniel.flanagan";
home.stateVersion = "24.05";
}
macos
];
};
};
diskoConfigurations = import ./disko;
templates = import ./templates/all.nix;
# homeConfigurations = {
# # TODO: non-system-specific home configurations?
# "deck" = let
# system = "x86_64-linux";
# in
# home-manager.lib.homeManagerConfiguration {
# pkgs = pkgsFor system;
# extraSpecialArgs = moduleArgs;
# modules = with self.outputs.homeManagerModules; [
# common
# {
# home.homeDirectory = "/home/deck";
# home.username = "deck";
# home.stateVersion = "24.05";
# }
# linux
# ];
# };
# workm1 = let
# system = "aarch64-darwin";
# in
# home-manager.lib.homeManagerConfiguration {
# pkgs = pkgsFor system;
# extraSpecialArgs = moduleArgs;
# modules = with self.outputs.homeManagerModules; [
# common
# {
# home.homeDirectory = "/Users/daniel.flanagan";
# home.username = "daniel.flanagan";
# home.stateVersion = "24.05";
# }
# macos
# ];
# };
# };
# TODO: nix-on-droid for phone terminal usage?
# TODO: nix-darwin for work?

View file

@ -1,9 +1,12 @@
{
overlays,
config,
lib,
inputs,
outputs,
pkgs,
colors,
sops-nix,
home-manager,
disko,
modulesPath,
...
}: let
@ -13,14 +16,14 @@ in {
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
inputs.sops-nix.nixosModules.sops
inputs.disko.nixosModules.disko
inputs.home-manager.nixosModules.home-manager
# (modulesPath + "/installer/scan/not-detected.nix")
# sops-nix.nixosModules.sops
# disko.nixosModules.disko
# home-manager.nixosModules.home-manager
]
++ [
./avahi.nix
./daniel.nix
# ./avahi.nix
# ./daniel.nix
];
hardware.enableRedistributableFirmware = true;
@ -174,7 +177,7 @@ in {
useXkbConfig = true;
earlySetup = true;
colors = with outputs.colors; [
colors = with colors; [
bg
red
green
@ -263,9 +266,9 @@ in {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
overlays.additions
overlays.modifications
overlays.unstable-packages
# You can also add overlays exported from other flakes:
# neovim-nightly-overlay.overlays.default

View file

@ -1,5 +0,0 @@
{inputs, ...}: {
imports = [
inputs.slippi.nixosModules.default
];
}

View file

@ -4,46 +4,35 @@
modules = [./base.nix];
};
# workstation
dragon = {
system = "x86_64-linux";
modules = [./dragon.nix];
modules = [
./dragon.nix
];
};
# primary laptop
foxtrot = {
system = "x86_64-linux";
modules = [./foxtrot.nix];
};
# entertainment convertible laptop
thablet = {
system = "x86_64-linux";
modules = [./thablet.nix];
};
# thinkpad backup laptop
thinker = {
system = "x86_64-linux";
modules = [./thinker.nix];
};
# TODO: stabilize these machines on nixpkgs-stable
# owned offsite backup
rascal = {
system = "x86_64-linux";
modules = [./rascal.nix];
};
# TODO: deploy this to the actual router
# home gateway
router = {
system = "x86_64-linux";
modules = [./router.nix];
};
# htpifour = {
# system = "aarch64-linux";
# modules = [./htpifour.nix];
# };
}

View file

@ -1,7 +1,13 @@
{
config,
inputs,
outputs,
# flake inputs
hardware,
slippi,
# inputs from our flake
diskoConfigurations,
nixosModules,
homeManagerModules,
# module args
# config,
lib,
pkgs,
...
@ -11,156 +17,163 @@
# support interacting with the windows drive
boot.supportedFilesystems = ["ntfs"];
imports = with outputs.nixosModules; [
outputs.diskoConfigurations.standard
inputs.hardware.nixosModules.common-cpu-amd
inputs.hardware.nixosModules.common-pc-ssd
outputs.nixosModules.pipewire-low-latency
outputs.nixosModules.music-production
imports = with nixosModules; [
# diskoConfigurations.standard
# hardware.nixosModules.common-cpu-amd
# hardware.nixosModules.common-pc-ssd
desktop-usage
podman
kde-plasma
postgres
wifi
# hyprland
printing
melee
steam
lutris
# slippi.outputs.nixosModules.default
# pipewire-low-latency
# music-production
# desktop-usage
# podman
# kde-plasma
# postgres
# wifi
# # hyprland
# printing
# steam
# lutris
];
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
gamescopeSession.enable = true;
};
# programs.steam = {
# enable = true;
# remotePlay.openFirewall = true;
# gamescopeSession.enable = true;
# };
environment = {
systemPackages = with pkgs; [
spotify
discord
radeontop
slack
godot_4
fractal
jdk17
prismlauncher
# variety
radeontop
sops
obs-studio
xh
];
};
# environment = {
# systemPackages = with pkgs; [
# spotify
# discord
# radeontop
# slack
# godot_4
# fractal
# jdk17
# prismlauncher
# # variety
# radeontop
# sops
# obs-studio
# xh
# ];
# };
home-manager.users.daniel = {
imports = with outputs.homeManagerModules; [
sway
pass
firefox-no-tabs
# wallpaper-manager
inputs.slippi.homeManagerModules.default
{
slippi.launcher = {
enable = true;
isoPath = "${config.home-manager.users.daniel.home.homeDirectory}/../games/roms/dolphin/melee.iso";
launchMeleeOnPlay = false;
};
}
hyprland
];
# home-manager.users.daniel = {
# imports = with homeManagerModules; [
# # sway
# # pass
# # firefox-no-tabs
# # # wallpaper-manager
# # slippi.homeManagerModules.default
# # {
# # slippi.launcher = {
# # enable = true;
# # isoPath = "${config.home-manager.users.daniel.home.homeDirectory}/../games/roms/dolphin/melee.iso";
# # launchMeleeOnPlay = false;
# # };
# # }
# # hyprland
# ];
services.mako.enable = lib.mkForce false; # don't use mako when using plasma
# services.mako.enable = lib.mkForce false; # don't use mako when using plasma
wayland.windowManager.hyprland = {
settings = {
env = [
"EWW_BAR_MON,1"
];
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
monitor = [
# "DP-2,3840x2160@60,-2160x0,1,transform,3"
"DP-3,3840x2160@120,${toString (builtins.ceil (2160 / 1.5))}x0,1"
# HDR breaks screenshare? "DP-3,3840x2160@120,${toString (builtins.ceil (2160 / 1.5))}x0,1,bitdepth,10"
# "desc:LG Display 0x0521,3840x2160@120,0x0,1"
# "desc:Dell Inc. DELL U2720Q D3TM623,3840x2160@60,3840x0,1.5,transform,1"
"DP-2,3840x2160@60,0x0,1.5,transform,1"
];
input = {
force_no_accel = true;
sensitivity = 1; # -1.0 - 1.0, 0 means no modification.
};
};
};
# wayland.windowManager.hyprland = {
# settings = {
# env = [
# "EWW_BAR_MON,1"
# ];
# # See https://wiki.hyprland.org/Configuring/Keywords/ for more
# monitor = [
# # "DP-2,3840x2160@60,-2160x0,1,transform,3"
# "DP-3,3840x2160@120,${toString (builtins.ceil (2160 / 1.5))}x0,1"
# # HDR breaks screenshare? "DP-3,3840x2160@120,${toString (builtins.ceil (2160 / 1.5))}x0,1,bitdepth,10"
# # "desc:LG Display 0x0521,3840x2160@120,0x0,1"
# # "desc:Dell Inc. DELL U2720Q D3TM623,3840x2160@60,3840x0,1.5,transform,1"
# "DP-2,3840x2160@60,0x0,1.5,transform,1"
# ];
# input = {
# force_no_accel = true;
# sensitivity = 1; # -1.0 - 1.0, 0 means no modification.
# };
# };
# };
wayland.windowManager.sway = {
config = {
output = {
"GIGA-BYTE TECHNOLOGY CO., LTD. AORUS FO48U 23070B000307" = {
mode = "3840x2160@120Hz";
position = "${toString (builtins.ceil (2160 / 1.5))},0";
};
# wayland.windowManager.sway = {
# config = {
# output = {
# "GIGA-BYTE TECHNOLOGY CO., LTD. AORUS FO48U 23070B000307" = {
# mode = "3840x2160@120Hz";
# position = "${toString (builtins.ceil (2160 / 1.5))},0";
# };
"Dell Inc. DELL U2720Q D3TM623" = {
# desktop left vertical monitor
mode = "3840x2160@60Hz";
transform = "90";
scale = "1.5";
position = "0,0";
};
};
# "Dell Inc. DELL U2720Q D3TM623" = {
# # desktop left vertical monitor
# mode = "3840x2160@60Hz";
# transform = "90";
# scale = "1.5";
# position = "0,0";
# };
# };
workspaceOutputAssign =
(
map
(ws: {
output = "GIGA-BYTE TECHNOLOGY CO., LTD. AORUS FO48U 23070B000307";
workspace = toString ws;
})
(lib.range 1 7)
)
++ (
map
(ws: {
output = "Dell Inc. DELL U2720Q D3TM623";
workspace = toString ws;
})
(lib.range 8 9)
);
};
};
};
# workspaceOutputAssign =
# (
# map
# (ws: {
# output = "GIGA-BYTE TECHNOLOGY CO., LTD. AORUS FO48U 23070B000307";
# workspace = toString ws;
# })
# (lib.range 1 7)
# )
# ++ (
# map
# (ws: {
# output = "Dell Inc. DELL U2720Q D3TM623";
# workspace = toString ws;
# })
# (lib.range 8 9)
# );
# };
# };
# };
services.printing.enable = true;
# services.printing.enable = true;
# TODO: https://nixos.wiki/wiki/Remote_LUKS_Unlocking
# # TODO: https://nixos.wiki/wiki/Remote_LUKS_Unlocking
# hardware
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.enable = true;
boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "ahci"];
boot.kernelModules = ["kvm-amd"];
# # hardware
# boot.loader.efi.canTouchEfiVariables = true;
# boot.loader.systemd-boot.enable = true;
# boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "ahci"];
# boot.kernelModules = ["kvm-amd"];
hardware.bluetooth = {
enable = true;
package = pkgs.bluez;
# powerOnBoot = true; # this is the default
};
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
# hardware.bluetooth = {
# enable = true;
# package = pkgs.bluez;
# # powerOnBoot = true; # this is the default
# settings = {
# General = {
# AutoConnect = true;
# MultiProfile = "multiple";
# };
# };
# };
# powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
networking = {
firewall = let
terraria = 7777;
stardew-valley = 24642;
in {
enable = true;
allowPing = true;
allowedTCPPorts = [22 terraria stardew-valley];
allowedUDPPorts = [terraria stardew-valley];
};
};
# networking = {
# firewall = let
# terraria = 7777;
# stardew-valley = 24642;
# in {
# enable = true;
# allowPing = true;
# allowedTCPPorts = [22 terraria stardew-valley];
# allowedUDPPorts = [terraria stardew-valley];
# };
# };
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "24.05";
# # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
# system.stateVersion = "24.05";
}

View file

@ -2,7 +2,7 @@
# This one brings our custom packages from the 'pkgs' directory
additions = final: _prev:
import ../packages {
pkgs = nixpkgs.legacyPackages.${final.system};
pkgs = import nixpkgs {inherit (final) system;};
};
# This one contains whatever you want to overlay

View file

@ -24,11 +24,14 @@
};
});
devShell = genPkgs (pkgs:
pkgs.mkShell {
devShells = genPkgs (pkgs: {
nix = pkgs.mkShell {
buildInputs = with pkgs; [nil alejandra];
inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
});
};
default = self.outputs.devShells.${pkgs.system}.nix;
});
# packages = genPkgs (pkgs: import ./pkgs {inherit pkgs;});
# overlays = import ./overlays self;