Skip to content

Commit

Permalink
flake: reorg common modules as flake outputs (#95)
Browse files Browse the repository at this point in the history
* initial committ

* move plymouth and printing to desktop modules

* rename commonModules -> common

* rename commonModules -> common

* move nix settings base -> common/nix

* nix fmt

* move baseModules to common/base
  • Loading branch information
alyraffauf authored Aug 22, 2024
1 parent 832f7fe commit 29bc4af
Show file tree
Hide file tree
Showing 22 changed files with 211 additions and 170 deletions.
23 changes: 23 additions & 0 deletions common/autoUpgrade.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
config,
lib,
...
}: {
environment.variables.FLAKE = lib.mkDefault "github:alyraffauf/nixcfg";

system.autoUpgrade = {
enable = true;
allowReboot = false;
dates = "02:00";
flags = ["--accept-flake-config"];
flake = config.environment.variables.FLAKE;
operation = "switch";
persistent = true;
randomizedDelaySec = "30min";

rebootWindow = {
lower = "02:00";
upper = "06:00";
};
};
}
36 changes: 3 additions & 33 deletions baseModules/default.nix → common/base.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
self: {lib, ...}: {
boot = {
consoleLogLevel = 0;
initrd.verbose = false;
loader.systemd-boot.configurationLimit = lib.mkDefault 10;
plymouth.enable = true;
};

{lib, ...}: {
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
console.useXkbConfig = true;
hardware.keyboard.qmk.enable = true;

Expand All @@ -18,28 +12,7 @@ self: {lib, ...}: {
nh.enable = true;
};

nix = {
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
randomizedDelaySec = "60min";
};

# Run GC when there is less than 100MiB left.
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';

optimise.automatic = true;

settings = {
auto-optimise-store = false;
experimental-features = ["nix-command" "flakes"];
};
};
networking.networkmanager.enable = true;

security = {
polkit.enable = true;
Expand Down Expand Up @@ -70,9 +43,6 @@ self: {lib, ...}: {
openFirewall = true;
settings.PasswordAuthentication = false;
};

printing.enable = true;
system-config-printer.enable = true;
};

sound.enable = true;
Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions common/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
nix = {
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
randomizedDelaySec = "60min";
};

# Run GC when there is less than 100MiB left.
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';

optimise.automatic = true;

settings = {
auto-optimise-store = false;
experimental-features = ["nix-command" "flakes"];

substituters = [
"https://alyraffauf.cachix.org"
"https://cache.nixos.org/"
"https://nix-community.cachix.org"
];

trusted-public-keys = [
"alyraffauf.cachix.org-1:GQVrRGfjTtkPGS8M6y7Ik0z4zLt77O0N25ynv2gWzDM="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];

trusted-users = ["aly"];
};
};
}
32 changes: 32 additions & 0 deletions common/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
pkgs,
self,
...
}: let
unstable = import self.inputs.nixpkgs-unstable {
system = pkgs.system;
};
in {
nixpkgs = {
config.allowUnfree = true; # Allow unfree packages

overlays = [
(final: prev: {
rofi-bluetooth =
prev.rofi-bluetooth.overrideAttrs
(old: {
version = "unstable-2024-07-25";

src = pkgs.fetchFromGitHub {
owner = "alyraffauf";
repo = old.pname;
rev = "50252e4a9aebe4899a6ef2f7bc11d91b7e4aa8ae";
sha256 = "sha256-o0Sr3/888L/2KzZZP/EcXx+8ZUzdHB/I/VIeVuJvJks=";
};
});

zed-editor = unstable.zed-editor;
})
];
};
}
7 changes: 7 additions & 0 deletions common/pkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
pkgs,
self,
...
}: {
environment.systemPackages = (with pkgs; [git inxi python3]) ++ [self.inputs.agenix.packages.${pkgs.system}.default];
}
25 changes: 10 additions & 15 deletions hosts/common/samba.nix → common/samba.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
config,
lib,
...
}: {
{config, ...}: {
fileSystems = let
fsType = "cifs";
options = [
Expand All @@ -17,18 +13,17 @@
"x-systemd.idle-timeout=60"
"x-systemd.mount-timeout=5s"
];
in
lib.attrsets.optionalAttrs (config.networking.hostName != "mauville") {
"/mnt/Archive" = {
inherit options fsType;
device = "//mauville/Archive";
};
in {
"/mnt/Archive" = {
inherit options fsType;
device = "//mauville/Archive";
};

"/mnt/Media" = {
inherit options fsType;
device = "//mauville/Media";
};
"/mnt/Media" = {
inherit options fsType;
device = "//mauville/Media";
};
};

home-manager.sharedModules = [
{
Expand Down
9 changes: 9 additions & 0 deletions common/tailscale.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{config, ...}: {
age.secrets.tailscaleAuthKey.file = ../secrets/tailscale/authKeyFile.age;

services.tailscale = {
enable = true;
openFirewall = true;
authKeyFile = config.age.secrets.tailscaleAuthKey.path;
};
}
27 changes: 19 additions & 8 deletions hosts/common/wifi.nix → common/wifi.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let
{config, ...}: let
mkOpenWiFi = ssid: {
connection.id = "${ssid}";
connection.type = "wifi";
Expand Down Expand Up @@ -30,11 +30,22 @@ let
}
);
in {
"Dustin's A54" = mkWPA2WiFi "Dustin's A54" "$DustinsA54PSK";
"Muchacho Guest" = mkOpenWiFi "Muchacho Guest";
"Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK";
"Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi";
"WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2";
"javapatron" = mkOpenWiFi "javapatron";
"wallace" = mkWPA2WiFi "wallace" "$wallacePSK";
age.secrets.wifi.file = ../secrets/wifi.age;

networking.networkmanager = {
enable = true;

ensureProfiles = {
environmentFiles = [config.age.secrets.wifi.path];
profiles = {
"Dustin's A54" = mkWPA2WiFi "Dustin's A54" "$DustinsA54PSK";
"javapatron" = mkOpenWiFi "javapatron";
"Muchacho Guest" = mkOpenWiFi "Muchacho Guest";
"Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK";
"Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi";
"wallace" = mkWPA2WiFi "wallace" "$wallacePSK";
"WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2";
};
};
};
}
12 changes: 10 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@
};

nixosModules = {
base = import ./baseModules self;
common-auto-upgrade = import ./common/autoUpgrade.nix;
common-base = import ./common/base.nix;
common-locale = import ./common/locale.nix;
common-mauville-share = import ./common/samba.nix;
common-nix = import ./common/nix.nix;
common-overlays = import ./common/overlays.nix;
common-pkgs = import ./common/pkgs.nix;
common-tailscale = import ./common/tailscale.nix;
common-wifi-profiles = import ./common/wifi.nix;

nixos = import ./nixosModules self;
users = import ./userModules self;
};
Expand All @@ -111,7 +120,6 @@
self.inputs.disko.nixosModules.disko
self.inputs.home-manager.nixosModules.home-manager
self.inputs.stylix.nixosModules.stylix
self.nixosModules.base
self.nixosModules.nixos
self.nixosModules.users
{
Expand Down
11 changes: 0 additions & 11 deletions hosts/common/default.nix

This file was deleted.

16 changes: 0 additions & 16 deletions hosts/common/network.nix

This file was deleted.

67 changes: 0 additions & 67 deletions hosts/common/nix.nix

This file was deleted.

12 changes: 0 additions & 12 deletions hosts/common/secrets.nix

This file was deleted.

9 changes: 8 additions & 1 deletion hosts/fallarbor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
...
}: {
imports = [
../common
./disko.nix
./home.nix
./secrets.nix
./stylix.nix
self.inputs.nixhw.nixosModules.framework-13-intel-11th
self.nixosModules.common-auto-upgrade
self.nixosModules.common-base
self.nixosModules.common-mauville-share
self.nixosModules.common-nix
self.nixosModules.common-overlays
self.nixosModules.common-pkgs
self.nixosModules.common-tailscale
self.nixosModules.common-wifi-profiles
];

boot.loader = {
Expand Down
Loading

0 comments on commit 29bc4af

Please sign in to comment.