Skip to content

Commit

Permalink
Init "Just Works" config checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
foofrog committed Jun 16, 2024
1 parent 451dc04 commit 17b08e0
Show file tree
Hide file tree
Showing 18 changed files with 178 additions and 96 deletions.
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<div align="center">
<img src="hexagons/caped-frogs.png" alt="Caped frogs in hexagon, a parody of the Nix & NixOS logo" widdth="200" height="200">
<img src="hexagons/caped-frogs.png" alt="Caped frogs in hexagon, a parody of the Nix & NixOS logo" width="200" height="200">
</div>

# UNDER CONSTRUCTION!
# Foo's Nix & NixOS Configuration

> [!CAUTION]
> This repository contains my configuration for NixOS system set up with Home Manager and Flakes, but as of now, it is unfortunately incomplete. Another thing to note is that **this is NOT the configuration I'm currently using**. My personal configuration has a different directory structure and a chaotic organization while configured a bit differently than this one. Thus, it has NOT been tested yet and might contain errors. I plan to swap this with my local setup, once this configuration's looking fairly good.
> [!IMPORTANT]
> This repository contains my NixOS setup with Home Manager and Flakes. While it isn't fully modular yet, it is mostly functional and **Just Works**. I plan to eventually develop it to a fully modular system and avoid unnecessary complexity to maintain readability in the codebase.
>
> Feel free to use it as reference (at your own risk) or additionally for testing. Consider making an issue if you find anything out of place or submit a pull request for fixes/improvements.
> Feel free to use it as reference for your own configurations.
>
> Albeit the setup isn't perfect, I hope it can provide some useful insights as I add informational comments wherever possible.
**Consider creating an issue addressing a problem or suggestions for improvement; otherwise, feel free to submit a pull request.**

## Directory structure (at a glance)

```
.
├── flake.lock
├── flake.nix
├── hosts
│   └── foobar
Expand All @@ -21,17 +26,20 @@
│   └── userspace.nix
└── modules
├── applications
│   ├── extra
│   │   └── steam.nix
│   ├── packages.nix
│   ├── programs
│   │   ├── opengl.nix
│   │   └── steam.nix
│   ├── programs.nix
│   └── services.nix
├── bootloader.nix
├── fonts.nix
├── graphics
│   ├── amd.nix
│   └── nvidia.nix
│   ├── nvidia.nix
│   └── opengl.nix
├── internet.nix
├── kernel.nix
├── localization.nix
├── peripherals
│   ├── audio.nix
Expand All @@ -47,13 +55,14 @@
└── root.nix
```

There are no `default.nix` files or `imports.nix` for imports, rather all OS and Home Manager modules are imported within `/hosts/foobar/systemwide.nix` and `/hosts/foobar/userspace.nix` respectively. These two files are intended (albeit not implemented yet, but ideally) to be used as module switches or toggles if you will, for my modules at `/modules`. `/modules/users/foo/home-depot/` directory serves as the deposit for the user's home configurations, handled by Home Manager.
Currently, all OS and Home Manager modules are imported within `/hosts/foobar/systemwide.nix` and `/hosts/foobar/userspace.nix` explicitly. These two files are ideally intended to be used as module switches or toggles if you will, for `/modules`. `/modules/users/foo/home-depot/` directory serves as a deposit for the user's home configurations managed by Home Manager.

### Lastly,
## Acknowledgements

I thank [TanvirOnGH](https://github.com/TanvirOnGH) for providing invaluable guidance that helped me make the hop from Arch (btw) to NixOS.
Despite initial hesitations, I'm happy I made the switch. Nix and NixOS differs from traditional distributions and thus has a bit of learning curve. However, staying ignorant of better alternatives is stupid and slows down progress in the long run. It's essential to step out the comfort zone, and embrace the coming hits of changes with open arms.
Nix and NixOS differs from traditional distributions and thus has a learning curve. One has to step out of their comfort zone but if able to learn, it's greatly benefiting. Same philosophy can apply for everything else in life.

[Tanvir's own repository](https://github.com/TanvirOnGH/nix-config) for NixOS setup has been immensely helpful in creating mine. Furthermore, [Krey's `nix-config`](https://github.com/Kreyren/nixos-config), [Fufezan](https://github.com/fufexan/dotfiles) and [Ryan Yin's](https://github.com/ryan4yin/nix-config) repositories were indispensable as learning sources and reference.
With that said, I'd like to thank:
- [Tanvir](https://github.com/TanvirOnGH), his invaluable guidance enabled me to make the hop to Nix & NixOS (from Arch, btw) and to come up with an initial setup. [His own Nix & NixOS ](https://github.com/TanvirOnGH/nix-config) configuration has been incredibly helpful in creating mine.
- [Krey](https://github.com/Kreyren/nixos-config), [Fufezan](https://github.com/fufexan/dotfiles), and [Ryan Yin](https://github.com/ryan4yin/nix-config) for their repositories, which were indispensable sources of learning and reference.
- [NixOS Discourse](https://discourse.nixos.org/), official NixOS community forum that helped me debug hours of pure pain.

A great resource is the unofficial [NixOS and Flakes Book](https://nixos-and-flakes.thiscute.world/introduction/).
13 changes: 11 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Prefer `nix <commmand>` command rather than `nix-<something>` commmands if flake
*/
inputs.nixpkgs.follows = "nixpkgs";
};

niri = {
url = github:YaLTeR/niri;
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs @ {
Expand All @@ -37,8 +42,12 @@ Prefer `nix <commmand>` command rather than `nix-<something>` commmands if flake
system = "x86_64-linux";
modules = [
./hosts/foobar/systemwide.nix

# Deploy Home Manager configuration automatically when running `nixos-switch rebuild` command

/*
INFO:
Including Home Manager as a module automatically deploys it during rebuild
Thus removing the need to rebuild Home Manager config seperately
*/
home-manager.nixosModules.home-manager
{
home-manager = {
Expand Down
13 changes: 10 additions & 3 deletions hosts/foobar/systemwide.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{...}: {
{pkgs, ...}: {
imports = [
./filesystems.nix
../../modules/applications/packages.nix
../../modules/applications/programs/opengl.nix
../../modules/applications/programs/steam.nix
../../modules/applications/programs.nix
../../modules/applications/services.nix
../../modules/bootloader.nix
../../modules/fonts.nix
../../modules/graphics/amd.nix
../../modules/graphics/nvidia.nix
../../modules/internet.nix
../../modules/kernel.nix
../../modules/localization.nix
../../modules/peripherals/audio.nix
../../modules/peripherals/bluetooth.nix
../../modules/peripherals/tablet.nix
../../modules/power-management.nix
../../modules/users/root.nix
../../modules/users/foo/user.nix
];

# Enable flakes for this configuration
Expand All @@ -20,7 +27,7 @@
INFO:
The value of `stateVersion` is the NixOS release version installed initially for this system
This is required for determining the default system state for that NixOS release
NOTE:
It is perfectly OK and recommended to leave it unchanged
Expand Down
5 changes: 3 additions & 2 deletions hosts/foobar/userspace.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{...}: {
imports = [
../../modules/users/foo/user.nix
../../modules/users/foo/home-depot/packages.nix
../../modules/users/foo/home-depot/programs.nix
];

programs.home-manager.enable = true;

/*
INFO:
The value of `home.stateVersion` is the Home Manager release version installed initially for this system
This is required to help avoid breakage when a new Home Manager release introduces backwards incompatible changes
NOTE:
It is perfectly OK and recommended to leave it unchanged even after a Home Manager update
*/
Expand Down
3 changes: 3 additions & 0 deletions modules/applications/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# TODO: Add a small comment description for each package in the list
macchina
helix
brillo

strace
ltrace
Expand All @@ -29,6 +30,8 @@
dmidecode # to read information about hardware from BIOS according to the SMBIOS/DMI standard
parted
gparted

spacedrive
];

# Set the default editor
Expand Down
6 changes: 1 addition & 5 deletions modules/applications/programs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@

gnupg.agent = {
enable = true;
pinentryPackage = pkgs.pinentry-gnome3;
enableSSHSupport = true;
};

helix = {
enable = true;
pinentryPackage = pkgs.pinentry-curses;
};
};
}
7 changes: 7 additions & 0 deletions modules/applications/programs/opengl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{pkgs, ...}: {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
}
21 changes: 21 additions & 0 deletions modules/applications/programs/steam.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{pkgs, ...}: {
programs = {
steam = {
enable = true;
# Start a Steam game in an optimized microcompositor that might fix some issues
gamescopeSession.enable = true;
};

# INFO: It applies temporary optimizations applies to the OS in-game, improving performance
gamemode.enable = true;
};

/*
NOTE:
Prepend `mangohud` in launch options within Steam client's General settings as `mangohud %command%`
to access its capabilities in-game. Same goes for other such programs.
*/
environment.systemPackages = with pkgs; [
mangohud
];
}
2 changes: 1 addition & 1 deletion modules/applications/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _: {
udisks2.enable = true;
devmon.enable = true;

# NOTE: Necessary for GnuPG to work correctly
# INFO: Necessary for GnuPG to work correctly
pcscd.enable = true;
};
}
6 changes: 4 additions & 2 deletions modules/bootloader.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{lib, ...}: {
boot.loader.systemd-boot = {
enable = true;

# Limit the number of generations that show up at boot entries
configurationLimit = lib.mkDefault 5;
configurationLimit = lib.mkDefault 10;

/*
WARN:
Expand All @@ -11,7 +13,7 @@
editor = false;

# Set the highest resolution available for boot console
consoleMode = lib.mkDefault "max";
# consoleMode = lib.mkDefault "max";
};

# Enable to allow the bootloader to modify EFI variables
Expand Down
15 changes: 9 additions & 6 deletions modules/fonts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
noto-fonts-emoji
noto-fonts-extra


# INFO: https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/data/fonts/nerdfonts/shas.nix
(nerdfonts.override {
fonts = [
Expand All @@ -24,11 +23,15 @@
];

# NOTE: Noto Color Emoji is explicitly specified to potentially override emojis from other fonts
fontconfig.defaultFonts = {
serif = ["Noto Serif" "Noto Serif CJK JP" "Noto Color Emoji"];
sansSerif = ["Noto Sans" "Noto Sans CJK JP" "Noto Color Emoji"];
monospace = ["0xProto Nerd Font" "Noto Color Emoji"];
emoji = ["Noto Color Emoji"];
fontconfig = {
enable = true;

defaultFonts = {
serif = ["Noto Serif" "Noto Serif CJK JP" "Noto Color Emoji"];
sansSerif = ["Noto Sans" "Noto Sans CJK JP" "Noto Color Emoji"];
monospace = ["0xProto Nerd Font" "Noto Color Emoji"];
emoji = ["Noto Color Emoji"];
};
};
};
}
7 changes: 7 additions & 0 deletions modules/graphics/opengl.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{pkgs, ...}: {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
}
4 changes: 2 additions & 2 deletions modules/internet.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
https://nixos.wiki/wiki/Wpa_supplicant_: {
_: {
networking = {
useDHCP = false;
# TODO: Implement functionality for generating hostname automatically based on the current host
hostName = "";
hostName = "foobar";

networkmanager = {
enable = true;
Expand Down
15 changes: 15 additions & 0 deletions modules/kernel.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{pkgs, ...}: {
boot = {

# Fetch the latest kernel! \(^ヮ^)/
kernelPackages = pkgs.linuxPackages_latest;
# kernelPackages = pkgs.linuxPackages_xanmod_latest; # INFO: https://xanmod.org/

kernelParams = [
# "quiet"
"mitigations=off"
"iommu=pt"
# "splash"
];
};
}
4 changes: 2 additions & 2 deletions modules/peripherals/audio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
It aims to offer capture and playback for both audio and video with minimal latency
It has support for PulseAudio-, JACK-, ALSA- and GStreamer-based applications
PipeWire has a great bluetooth support, it can be a good alternative to PulseAudio
https://nixos.wiki/wiki/PipeWire
*/
services.pipewire = {
Expand All @@ -27,7 +27,7 @@

# NOTE: `rtkit` is optional but enabling it is recommended
security.rtkit.enable = true;

# NOTE: Both of these may conflict with `pipewire` so disabling them is recommended
sound.enable = false;
hardware.pulseaudio.enable = false;
Expand Down
12 changes: 8 additions & 4 deletions modules/users/foo/home-depot/packages.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{pkgs, ...}: {
home.packages = with pkgs; [
kitty

bat
bottom
eza
fuzzel
skim
xplr
zoxide

firefox

# Diagnostic
macchina
bottom
Expand All @@ -19,11 +25,9 @@
pigz
rar

# Development
zulu

# UI/UX
niri
swww

jetbrains-mono
noto-fonts
Expand All @@ -35,7 +39,7 @@
asciiquarium
cmatrix
cbonsai
cowsat
cowsay
figlet
lolcat
];
Expand Down
Loading

0 comments on commit 17b08e0

Please sign in to comment.