flake #7

Merged
don merged 16 commits from flake into main 2023-09-20 21:58:06 -05:00
20 changed files with 253 additions and 125 deletions

2
.gitignore vendored
View file

@ -16,3 +16,5 @@
# .nfs files are created when an open file is removed but is still being accessed # .nfs files are created when an open file is removed but is still being accessed
.nfs* .nfs*
*.swp *.swp
result
*.qcow2

66
flake.lock generated Normal file
View file

@ -0,0 +1,66 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1694465129,
"narHash": "sha256-8BQiuobMrCfCbGM7w6Snx+OBYdtTIm0+cGVaKwQ5BFg=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "9787dffff5d315c9593d3f9fb0f9bf2097e1b57b",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"repo": "home-manager",
"type": "github"
}
},
"nixos-hardware": {
"locked": {
"lastModified": 1694710316,
"narHash": "sha256-uRh46iIC86D8BD1wCDA5gRrt+hslUXiD0kx/UjnjBcs=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "570256327eb6ca6f7bebe8d93af49459092a0c43",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694422566,
"narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

72
flake.nix Normal file
View file

@ -0,0 +1,72 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs: {
nixosConfigurations = let
workstation = {
system = "x86_64-linux";
modules = [
./workstation
inputs.home-manager.nixosModules.home-manager
./home
];
};
in {
loki = inputs.nixpkgs.lib.nixosSystem {
modules = workstation.modules ++ [
{
networking.hostName = "loki";
}
./wm/sway
./hosts/loki/hardware-configuration.nix
];
};
smaug = inputs.nixpkgs.lib.nixosSystem {
modules = workstation.modules ++ [
{
networking.hostName = "smaug";
}
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x260
./wm/sway
./hosts/smaug/hardware-configuration.nix
];
};
dragon = inputs.nixpkgs.lib.nixosSystem {
modules = workstation.modules ++ [
{
networking.hostName = "dragon";
}
inputs.nixos-hardware.nixosModules. google-pixelbook
./wm/sway
./hosts/dragon/hardware-configuration.nix
];
};
eve = inputs.nixpkgs.lib.nixosSystem {
modules = workstation.modules ++ [
{
networking.hostName = "eve";
}
inputs.nixos-hardware.nixosModules. google-pixelbook
./wm/sway
./hosts/eve/hardware-configuration.nix
];
};
vm2 = inputs.nixpkgs.lib.nixosSystem {
modules = workstation.modules ++ [
{
services.getty.autologinUser = "don";
networking.hostName = "vm2";
}
./wm/sway
];
};
};
};
}

View file

@ -1,16 +1,21 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [ home-manager.useGlobalPkgs = true;
./packages-cli.nix home-manager.useUserPackages = true;
./packages-gui.nix home-manager.users.don = {
./services.nix imports = [
]; ./packages-cli.nix
home = { ./packages-gui.nix
./services.nix
#./systemd.nix # TODO Fix systemd under flake
];
home = {
username = "don"; username = "don";
homeDirectory = "/home/don"; homeDirectory = "/home/don";
stateVersion = "23.05"; stateVersion = "23.05";
}; };
programs.home-manager.enable = true; programs.home-manager.enable = true;
programs.go.enable = true; programs.go.enable = true;
};
} }

View file

@ -18,14 +18,13 @@
file file
fzf fzf
gdu gdu
git-crypt
gitFull
gitui gitui
gh gh
gnumake gnumake
gnupg gnupg
gping gping
gtop gtop
htop
hugo hugo
jq jq
keychain keychain

View file

@ -21,7 +21,6 @@
firefox firefox
flameshot flameshot
font-awesome font-awesome
fractal-next
gnome.gnome-tweaks gnome.gnome-tweaks
gnome.simple-scan gnome.simple-scan
gnumeric gnumeric

View file

@ -1,11 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "ace";
}

View file

@ -1,11 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "dragon";
}

View file

@ -8,7 +8,7 @@
[ (modulesPath + "/installer/scan/not-detected.nix") [ (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
@ -33,7 +33,9 @@
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s25.useDHCP = lib.mkDefault true; # networking.interfaces.enp0s25.useDHCP = lib.mkDefault true;
# networking.interfaces.tailscale0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true; # networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -1,12 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
<nixos-hardware/google/pixelbook>
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "eve";
}

View file

@ -35,5 +35,6 @@
# networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true; # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -1,12 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
<nixos-hardware/dell/xps/13-9310>
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "loki";
}

View file

@ -0,0 +1,41 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "usbhid" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/3d7cbefa-d25f-4502-bb8e-f6cfca8bc682";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/5547-270C";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/e5906bd1-ea2b-4e96-9393-3d5da127e0ac"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp60s0u1u3u4.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,11 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "pocket2";
}

View file

@ -1,12 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
<nixos-hardware/lenovo/thinkpad/x260>
/etc/nixos/hardware-configuration.nix
../../workstation
../../wm/sway
];
networking.hostName = "smaug";
}

View file

@ -0,0 +1,42 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/sda2";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/sda1";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/sda3"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,10 +0,0 @@
{ config, pkgs, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
../../server/configuration.nix
];
networking.hostName = "vm1";
}

6
makefile Normal file
View file

@ -0,0 +1,6 @@
all:
doas nixos-rebuild switch --flake .#$${HOSTNAME_SHORT}
vm:
doas nixos-rebuild switch --flake .#vm2 && result/bin/run-*-vm

View file

@ -1,30 +1,15 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
# bash script to let dbus know about important env variables and
# propogate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile { dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment"; name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment"; destination = "/bin/dbus-sway-environment";
executable = true; executable = true;
text = '' text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
''; '';
}; };
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile { configure-gtk = pkgs.writeTextFile {
name = "configure-gtk"; name = "configure-gtk";
destination = "/bin/configure-gtk"; destination = "/bin/configure-gtk";
@ -38,8 +23,6 @@ let
gsettings set $gnome_schema gtk-theme 'Dracula' gsettings set $gnome_schema gtk-theme 'Dracula'
''; '';
}; };
in in
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -62,28 +45,10 @@ in
wayland wayland
wl-clipboard wl-clipboard
]; ];
# xdg-desktop-portal works by exposing a series of D-Bus interfaces
# known as portals under a well-known name
# (org.freedesktop.portal.Desktop) and object path
# (/org/freedesktop/portal/desktop).
# The portal interfaces include APIs for file access, opening URIs,
# printing and others.
services.dbus.enable = true; services.dbus.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
# gtk portal needed to make gtk apps happy
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
#gtkUsePortal = true;
};
# enable sway window manager
programs.sway = { programs.sway = {
enable = true; enable = true;
wrapperFeatures.gtk = true; wrapperFeatures.gtk = true;
}; };
services.greetd.package = "greetd.wlgreet"; services.greetd.package = "greetd.wlgreet";
} }

View file

@ -124,7 +124,12 @@ in
}; };
security.rtkit.enable = true; security.rtkit.enable = true;
xdg.portal.enable = true; # only needed if you are not doing Gnome xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
#gtkUsePortal = true;
};
users.users.don = { users.users.don = {
isNormalUser = true; isNormalUser = true;
@ -149,6 +154,8 @@ in
nix-bash-completions nix-bash-completions
btop btop
espeak-classic espeak-classic
git-crypt
gitFull
headsetcontrol headsetcontrol
home-manager home-manager
hunspell hunspell