Skip to content

Commit

Permalink
feat(nixos): Add laptop configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Nov 24, 2024
1 parent c202995 commit 7f99e82
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 17 deletions.
33 changes: 33 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
inherit inputs;
isServer = true;
isLinux = true;
isLaptop = false;
isDarwin = false;
};
system = "x86_64-linux";
Expand All @@ -59,6 +60,7 @@
inherit inputs;
isServer = true;
isLinux = true;
isLaptop = false;
isDarwin = false;
};
};
Expand All @@ -71,6 +73,7 @@
isServer = false;
isDarwin = false;
isLinux = true;
isLaptop = false;
};
system = "x86_64-linux";
modules = [
Expand All @@ -87,6 +90,36 @@
isServer = false;
isDarwin = false;
isLinux = true;
isLaptop = false;
};
};
}
];
};
laptop = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
isServer = false;
isDarwin = false;
isLinux = true;
isLaptop = true;
};
system = "x86_64-linux";
modules = [
./nixos-modules/common.nix
./hosts/laptop
home-manager.nixosModules.home-manager
{
home-manager = {
backupFileExtension = "backup";
useUserPackages = true;
users.mat = import ./home-manager/home.nix;
extraSpecialArgs = {
inherit inputs;
isServer = false;
isDarwin = false;
isLinux = true;
isLaptop = true;
};
};
}
Expand Down
Binary file added home-manager/discord.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions home-manager/home.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{ inputs, config, pkgs, lib, isDarwin, isLinux, ... }:
let
discordIcon = pkgs.fetchurl {
url =
"https://static-00.iconduck.com/assets.00/apps-discord-icon-2048x2048-hkrl0hxr.png";
hash = "sha256-e3AT1zekZJEYRm+S9wwMuJb+G2/zSOZSKJztHGKnOiY=";
};
in {
{
nixpkgs.overlays = [
(final: prev:
(import ../packages {
Expand Down Expand Up @@ -64,7 +58,7 @@ in {
xdg = {
enable = true;
# for discord app icon
dataFile."icons/discord.png".source = discordIcon;
dataFile."icons/discord.png".source = ./discord.png;
# link config files, if a dedicated module exists (below)
# it will handle its own config
configFile = {
Expand Down
4 changes: 2 additions & 2 deletions home-manager/modules/_1password-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let
#!${pkgs.bash}/bin/bash
# TODO figure out a way to do this without silently depending on `op` being on $PATH
# using `$\{pkgs._1password}/bin/op` results in unable to connect to desktop app
PASSWORD="$(op item get "System Password" --fields password)"
PASSWORD="$(op item get "System Password" --fields password --reveal)"
if [[ -z "$PASSWORD" ]]; then
echo "Failed to get password from 1Password."
read -s -p "Password: " PASSWORD
Expand All @@ -13,7 +13,7 @@ let
echo $PASSWORD
'';
in {
home.packages = with pkgs; [ _1password ];
home.packages = with pkgs; [ _1password-cli ];
imports = [ inputs._1password-shell-plugins.hmModules.default ];
programs = {
fish = {
Expand Down
6 changes: 4 additions & 2 deletions home-manager/modules/fish.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, isDarwin, isLinux, isServer, ... }: {
{ pkgs, lib, isDarwin, isLinux, isServer, isLaptop, ... }: {
home.sessionVariables = {
DOTNET_CLI_TELEMETRY_OPTOUT = "1";
HOMEBREW_NO_ANALYTICS = "1";
Expand Down Expand Up @@ -107,7 +107,9 @@
"home-manager switch --flake ~/git/dotfiles/.#mac"
else if isServer then
"sudo nixos-rebuild switch --flake ~/git/dotfiles/.#server"
else
else if isLaptop then
"sudo nixos-rebuild switch --flake ~/git/dotfiles/.#laptop"
else
"sudo nixos-rebuild switch --flake ~/git/dotfiles/.#pc"}
'';
};
Expand Down
5 changes: 2 additions & 3 deletions home-manager/modules/gnome/dconf.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, lib, isLaptop, ... }:
let
wallpaperImg = pkgs.fetchurl {
url =
Expand Down Expand Up @@ -39,8 +39,7 @@ in {
"signal-desktop.desktop"
"firefox.desktop"
"vesktop.desktop"
"steam.desktop"
];
] ++ lib.lists.optionals (!isLaptop) [ "steam.desktop" ];
inherit enabled-extensions;
};
"org/gnome/desktop/interface" = {
Expand Down
42 changes: 42 additions & 0 deletions hosts/laptop/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ pkgs, ... }: {
networking = {
hostName = "nixos-laptop";
networkmanager.enable = true;
};

imports = [
../../nixos-modules/desktop_environment.nix
../../nixos-modules/_1password.nix
../../nixos-modules/allowed-unfree.nix
./hardware-configuration.nix
];

programs = {
fish.enable = true;

neovim = {
enable = true;
defaultEditor = true;
};
};

environment.variables = {
SUDO_EDITOR = "nvim";
EDITOR = "nvim";
};

services = {
# Enable the X11 windowing system.
xserver.enable = true;
mullvad-vpn.enable = true;
tailscale.enable = true;
flatpak.enable = true;
};

boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
};
}
42 changes: 42 additions & 0 deletions hosts/laptop/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -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" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-uuid/71f0a300-d3af-4d9c-bcae-4da7b2cb7cdd";
fsType = "ext4";
};

boot.initrd.luks.devices."luks-478962df-c7d5-4e0c-9f30-f5435e27612a".device = "/dev/disk/by-uuid/478962df-c7d5-4e0c-9f30-f5435e27612a";

fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/EFA5-597E";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};

swapDevices = [ ];

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

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
1 change: 1 addition & 0 deletions hosts/pc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
services = {
# Enable the X11 windowing system.
xserver.enable = true;
xserver.videoDrivers = [ "nvidia" ];
mullvad-vpn.enable = true;
tailscale.enable = true;
flatpak.enable = true;
Expand Down
2 changes: 1 addition & 1 deletion nixos-modules/_1password.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
programs._1password = { enable = true; };
programs._1password-cli = { enable = true; };
programs._1password-gui = {
enable = true;
polkitPolicyOwners = [ "mat" ];
Expand Down
1 change: 0 additions & 1 deletion nixos-modules/desktop_environment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ in {
displayManager.defaultSession = "gnome-xorg";
xserver = {
enable = true;
videoDrivers = [ "nvidia" ];
desktopManager.gnome.enable = true;
displayManager = { gdm.enable = true; };
};
Expand Down

0 comments on commit 7f99e82

Please sign in to comment.