Skip to content

Commit

Permalink
feat: implemented existing targets in flake config
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarrio committed Sep 3, 2023
1 parent 2aecc51 commit 361382c
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 81 deletions.
78 changes: 39 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Wimpy's NixOS and Home Manager Configuration";
description = "tcarrio's NixOS and Home Manager Configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
# You can access packages and modules from different nixpkgs revs at the
Expand Down Expand Up @@ -39,58 +39,58 @@
in
{
# home-manager switch -b backup --flake $HOME/Zero/nix-config
# nix build .#homeConfigurations."tom@ripper".activationPackage
# nix build .#homeConfigurations."tcarrio@ripper".activationPackage
homeConfigurations = {
# .iso images
"nuc@iso-nuc" = libx.mkHome { hostname = "iso-nuc"; username = "nixos"; };
"tk1@iso-tk1" = libx.mkHome { hostname = "iso-tk1"; username = "nixos"; };

# Workstations
"tom@designare" = libx.mkHome { hostname = "designare"; username = "tom"; desktop = "pantheon"; };
"tom@glass" = libx.mkHome { hostname = "glass"; username = "tom"; desktop = "pantheon"; };
"tom@micropc" = libx.mkHome { hostname = "micropc"; username = "tom"; desktop = "pantheon"; };
"tom@p1" = libx.mkHome { hostname = "p1"; username = "tom"; desktop = "pantheon"; };
"tom@p2-max" = libx.mkHome { hostname = "p2-max"; username = "tom"; desktop = "pantheon"; };
"tom@ripper" = libx.mkHome { hostname = "ripper"; username = "tom"; desktop = "pantheon"; };
"tom@t510" = libx.mkHome { hostname = "t510"; username = "tom"; desktop = "pantheon"; };
"tom@trooper" = libx.mkHome { hostname = "trooper"; username = "tom"; desktop = "pantheon"; };
"tom@vm" = libx.mkHome { hostname = "vm"; username = "tom"; desktop = "pantheon"; };
"tom@win2" = libx.mkHome { hostname = "win2"; username = "tom"; desktop = "pantheon"; };
"tom@win-max" = libx.mkHome { hostname = "win-max"; username = "tom"; desktop = "pantheon"; };
"tom@zed" = libx.mkHome { hostname = "zed"; username = "tom"; desktop = "pantheon"; };
"tcarrio@designare" = libx.mkHome { hostname = "designare"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@glass" = libx.mkHome { hostname = "glass"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@micropc" = libx.mkHome { hostname = "micropc"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@p1" = libx.mkHome { hostname = "p1"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@p2-max" = libx.mkHome { hostname = "p2-max"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@ripper" = libx.mkHome { hostname = "ripper"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@t510" = libx.mkHome { hostname = "t510"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@trooper" = libx.mkHome { hostname = "trooper"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@vm" = libx.mkHome { hostname = "vm"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@win2" = libx.mkHome { hostname = "win2"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@win-max" = libx.mkHome { hostname = "win-max"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@zed" = libx.mkHome { hostname = "zed"; username = "tcarrio"; desktop = "pantheon"; };

# Servers
"tom@brix" = libx.mkHome { hostname = "brix"; username = "tom"; };
"tom@skull" = libx.mkHome { hostname = "skull"; username = "tom"; };
"tom@vm-mini" = libx.mkHome { hostname = "vm-mini"; username = "tom"; };
"tcarrio@brix" = libx.mkHome { hostname = "brix"; username = "tcarrio"; };
"tcarrio@skull" = libx.mkHome { hostname = "skull"; username = "tcarrio"; };
"tcarrio@vm-mini" = libx.mkHome { hostname = "vm-mini"; username = "tcarrio"; };
};

nixosConfigurations = {
# .iso images
# - nix build .#nixosConfigurations.{iso-console|iso-desktop}.config.system.build.isoImage
iso-nuc = libx.mkHost { type = "iso"; hostname = "iso-nuc"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
iso-tk1 = libx.mkHost { type = "iso"; hostname = "iso-tk1"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-console = libx.mkHost { type = "iso"; hostname = "iso-console"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
iso-desktop = libx.mkHost { type = "iso"; hostname = "iso-desktop"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-micropc = libx.mkHost { type = "iso"; hostname = "micropc"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-win2 = libx.mkHost { type = "iso"; hostname = "win2"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-win-max = libx.mkHost { type = "iso"; hostname = "iso-win-max"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-nuc = libx.mkHost { systemType = "iso"; hostname = "iso-nuc"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
iso-tk1 = libx.mkHost { systemType = "iso"; hostname = "iso-tk1"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-console = libx.mkHost { systemType = "iso"; hostname = "iso-console"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
iso-desktop = libx.mkHost { systemType = "iso"; hostname = "iso-desktop"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-micropc = libx.mkHost { systemType = "iso"; hostname = "micropc"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-win2 = libx.mkHost { systemType = "iso"; hostname = "win2"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };
iso-win-max = libx.mkHost { systemType = "iso"; hostname = "iso-win-max"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "pantheon"; };

# Workstations
# - sudo nixos-rebuild switch --flake $HOME/Zero/nix-config
# - nix build .#nixosConfigurations.ripper.config.system.build.toplevel
designare = libx.mkHost { type = "workstation"; hostname = "designare"; username = "tom"; desktop = "pantheon"; };
glass = libx.mkHost { type = "workstation"; hostname = "glass"; username = "tom"; desktop = "sway"; };
p1 = libx.mkHost { type = "workstation"; hostname = "p1"; username = "tom"; desktop = "pantheon"; };
p2-max = libx.mkHost { type = "workstation"; hostname = "p2-max"; username = "tom"; desktop = "pantheon"; };
micropc = libx.mkHost { type = "workstation"; hostname = "micropc"; username = "tom"; desktop = "pantheon"; };
ripper = libx.mkHost { type = "workstation"; hostname = "ripper"; username = "tom"; desktop = "pantheon"; };
t510 = libx.mkHost { type = "workstation"; hostname = "t510"; username = "tom"; desktop = "pantheon"; };
trooper = libx.mkHost { type = "workstation"; hostname = "trooper"; username = "tom"; desktop = "pantheon"; };
vm = libx.mkHost { type = "workstation"; hostname = "vm"; username = "tom"; desktop = "pantheon"; };
win2 = libx.mkHost { type = "workstation"; hostname = "win2"; username = "tom"; desktop = "pantheon"; };
win-max = libx.mkHost { type = "workstation"; hostname = "win-max"; username = "tom"; desktop = "pantheon"; };
zed = libx.mkHost { type = "workstation"; hostname = "zed"; username = "tom"; desktop = "pantheon"; };
designare = libx.mkHost { systemType = "workstation"; hostname = "designare"; username = "tcarrio"; desktop = "pantheon"; };
glass = libx.mkHost { systemType = "workstation"; hostname = "glass"; username = "tcarrio"; desktop = "sway"; };
p1 = libx.mkHost { systemType = "workstation"; hostname = "p1"; username = "tcarrio"; desktop = "pantheon"; };
p2-max = libx.mkHost { systemType = "workstation"; hostname = "p2-max"; username = "tcarrio"; desktop = "pantheon"; };
micropc = libx.mkHost { systemType = "workstation"; hostname = "micropc"; username = "tcarrio"; desktop = "pantheon"; };
ripper = libx.mkHost { systemType = "workstation"; hostname = "ripper"; username = "tcarrio"; desktop = "pantheon"; };
t510 = libx.mkHost { systemType = "workstation"; hostname = "t510"; username = "tcarrio"; desktop = "pantheon"; };
trooper = libx.mkHost { systemType = "workstation"; hostname = "trooper"; username = "tcarrio"; desktop = "pantheon"; };
vm = libx.mkHost { systemType = "workstation"; hostname = "vm"; username = "tcarrio"; desktop = "pantheon"; };
win2 = libx.mkHost { systemType = "workstation"; hostname = "win2"; username = "tcarrio"; desktop = "pantheon"; };
win-max = libx.mkHost { systemType = "workstation"; hostname = "win-max"; username = "tcarrio"; desktop = "pantheon"; };
zed = libx.mkHost { systemType = "workstation"; hostname = "zed"; username = "tcarrio"; desktop = "pantheon"; };

# Servers
# Can be executed locally:
Expand All @@ -100,9 +100,9 @@
# - nixos-rebuild switch --fast --flake .#${HOST} \
# --target-host ${USERNAME}@${HOST}.${TAILNET} \
# --build-host ${USERNAME}@${HOST}.${TAILNET}
brix = libx.mkHost { type = "server"; hostname = "brix"; username = "tom"; };
skull = libx.mkHost { type = "server"; hostname = "skull"; username = "tom"; };
vm-mini = libx.mkHost { type = "server"; hostname = "vm-mini"; username = "tom"; };
brix = libx.mkHost { systemType = "server"; hostname = "brix"; username = "tcarrio"; };
skull = libx.mkHost { systemType = "server"; hostname = "skull"; username = "tcarrio"; };
vm-mini = libx.mkHost { systemType = "server"; hostname = "vm-mini"; username = "tcarrio"; };
};

# Devshell for bootstrapping; acessible via 'nix develop' or 'nix-shell' (legacy)
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# - installer: can be one of the following:
# - "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
# - "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"
mkHost = { hostname, username, desktop ? null, installer ? null }: inputs.nixpkgs.lib.nixosSystem {
mkHost = { hostname, username, desktop ? null, installer ? null, systemType ? null }: inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs desktop hostname username stateVersion;
inherit inputs outputs desktop hostname username stateVersion systemType;
};
modules = [
../nixos
Expand Down
8 changes: 8 additions & 0 deletions nixos/_mixins/av/vulkan.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs, ... }:
{
# enable video support and vulkan drivers
hardware.opengl.driSupport32Bit = true;
hardware.opengl.enable = true;
hardware.pulseaudio.support32Bit = true;
environment.systemPackages = [ pkgs.vulkan-tools ];
}
4 changes: 4 additions & 0 deletions nixos/_mixins/desktop/discord.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ pkgs, ...}:
{
environment.systemPackages = with pkgs; [ discord ];
}
12 changes: 12 additions & 0 deletions nixos/_mixins/desktop/lutris.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs, ...}:
{
imports = [
../av/vulkan.nix
];

environment.systemPackages = with pkgs; [
lutris
wineWowPackages.stable
winetricks
];
}
4 changes: 4 additions & 0 deletions nixos/_mixins/desktop/spotify.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ spotify ];
}
4 changes: 2 additions & 2 deletions nixos/_mixins/services/xdg-portal.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_: {
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
enable = false;
# xdgOpenUsePortal = true;
};
}
37 changes: 37 additions & 0 deletions nixos/_mixins/users/tcarrio/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ config, desktop, lib, pkgs, ... }:
let
ifExists = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
in
{
# Only include desktop components if one is supplied.
imports = [ ] ++ lib.optional (builtins.isString desktop) ./desktop.nix;

environment.systemPackages = [
pkgs.yadm # Terminal dot file manager
];

users.users.tcarrio = {
description = "Tom Carrio";
extraGroups = [
"audio"
"input"
"networkmanager"
"users"
"video"
"wheel"
]
++ ifExists [
"docker"
"podman"
];
# mkpasswd -m sha-512
hashedPassword = "$6$uLtXsdZpgBd/iVao$L3Lk9vmQMOfZrARIyl6Sq6ZbU91d53dWQteZADxkgLJ8FZUet.L4E73LnmVccJUGdAUcMQ1cuISS9j0XygM2Q1";
homeMode = "0755";
isNormalUser = true;
openssh.authorizedKeys.keys = [
# Add any authorized keys for SSH access here
];
packages = [ pkgs.home-manager ];
shell = pkgs.fish;
};
}
45 changes: 45 additions & 0 deletions nixos/_mixins/users/tcarrio/desktop.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ desktop, pkgs, lib, ... }: {
imports = [
../../desktop/brave.nix
../../desktop/chromium.nix
../../desktop/firefox.nix
#../../desktop/evolution.nix
../../desktop/google-chrome.nix
../../desktop/lutris.nix
../../desktop/microsoft-edge.nix
../../desktop/obs-studio.nix
../../desktop/spotify.nix
../../desktop/tilix.nix
../../desktop/vscode.nix
] ++ lib.optional (builtins.pathExists (../.. + "/desktop/${desktop}-apps.nix")) ../../desktop/${desktop}-apps.nix;

environment.systemPackages = with pkgs; [
audio-recorder
gimp-with-plugins
gnome.gnome-clocks
gnome.dconf-editor
gnome.gnome-sound-recorder
inkscape
libreoffice
meld
netflix
pick-colour-picker
slack

# Fast moving apps use the unstable branch
unstable.discord
];

# programs = {
# chromium = {
# extensions = [
# "kbfnbcaeplbcioakkpcpgfkobkghlhen" # Grammarly
# "cjpalhdlnbpafiamejdnhcphjbkeiagm" # uBlock Origin
# "mdjildafknihdffpkfmmpnpoiajfjnjd" # Consent-O-Matic
# "mnjggcdmjocbbbhaepdhchncahnbgone" # SponsorBlock for YouTube
# "gebbhagfogifgggkldgodflihgfeippi" # Return YouTube Dislike
# "edlifbnjlicfpckhgjhflgkeeibhhcii" # Screenshot Tool
# ];
# };
# };
}
6 changes: 3 additions & 3 deletions nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ config, desktop, hostname, inputs, lib, modulesPath, outputs, pkgs, stateVersion, username, ... }: {
{ config, desktop, hostname, inputs, lib, modulesPath, outputs, pkgs, stateVersion, systemType, username, ... }: {
imports = [
inputs.disko.nixosModules.disko
inputs.vscode-server.nixosModules.default
(modulesPath + "/installer/scan/not-detected.nix")
./${hostname}
./${systemType}/${hostname}
./_mixins/services/firewall.nix
./_mixins/services/fwupd.nix
./_mixins/services/kmscon.nix
Expand Down Expand Up @@ -32,7 +32,7 @@

console = {
font = "${pkgs.tamzen}/share/consolefonts/TamzenForPowerline10x20.psf";
keyMap = "uk";
keyMap = "us";
packages = with pkgs; [ tamzen ];
};

Expand Down
51 changes: 16 additions & 35 deletions nixos/workstation/glass/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,34 @@
# SATA: 500GB SSD
# SATA: 2TB SSHD

{ inputs, lib, pkgs, ... }:
{ inputs, lib, config, pkgs, modulesPath, ... }:
{
imports = [
# TODO: Incorporate diskos
# (import ./disks.nix { })
./hardware-configuration.nix

inputs.nixos-hardware.nixosModules.common-cpu-amd
inputs.nixos-hardware.nixosModules.common-gpu-nvidia
inputs.nixos-hardware.nixosModules.common-gpu-nvidia-nonprime
inputs.nixos-hardware.nixosModules.common-pc
inputs.nixos-hardware.nixosModules.common-pc-ssd
# (import ./disks.nix { }) # TODO: Incorporate diskos
../_mixins/hardware/systemd-boot.nix
../_mixins/services/bluetooth.nix
../_mixins/services/pipewire.nix
../_mixins/services/tailscale.nix
../_mixins/virt
];

swapDevices = [{
device = "/swap";
size = 4096;
}];
../../_mixins/hardware/systemd-boot.nix
../../_mixins/services/pipewire.nix
../../_mixins/services/tailscale.nix
../../_mixins/virt
];

boot = {
kernelPackages = pkgs.linuxPackages_6_3;
kernelPackages = pkgs.linuxPackages_latest;
blacklistedKernelModules = lib.mkDefault [ "nouveau" ];
# initrd.kernelModules = [ ];
# initrd.availableKernelModules = [ "ahci" "nvme" "uas" "usbhid" "sd_mod" "xhci_pci" ];
initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" ];
kernelModules = [ "kvm-amd" "nvidia" ];
extraModulePackages = [ ];
initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
initrd.kernelModules = [ ];
kernelModules = [ "kvm-amd" "nvidia" ];
# kernelModules = [ "kvm-amd" ];
};

fileSystems."/" =
{ device = "/dev/disk/by-uuid/8f20ce4f-86f8-43cb-9cb4-fac7274e1678";
fsType = "ext4";
};

fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/3B44-A0B6";
fsType = "vfat";
};

fileSystems."/data/ssd2" =
{ device = "/dev/disk/by-uuid/f19f8a02-91b4-4238-9a66-575755caac2e";
fsType = "ext4";
};

swapDevices = [ ];

environment.systemPackages = with pkgs; [
nvtop
];
Expand Down
52 changes: 52 additions & 0 deletions nixos/workstation/glass/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-uuid/2c4292c6-c365-4c2a-a762-318eec1a0883";
fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" ];
};

fileSystems."/home" =
{ device = "/dev/disk/by-uuid/2c4292c6-c365-4c2a-a762-318eec1a0883";
fsType = "btrfs";
options = [ "subvol=home" "compress=zstd" ];
};

fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/2c4292c6-c365-4c2a-a762-318eec1a0883";
fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ];
};

fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/75E4-D8D4";
fsType = "vfat";
};

swapDevices =
[ { device = "/dev/disk/by-uuid/1222e371-0e03-447b-ae1c-e511900edabc"; }
];

# 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.enp3s0.useDHCP = lib.mkDefault true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

0 comments on commit 361382c

Please sign in to comment.