···33This repo contains the flake I use to configure any of my NixOS-configured
44devices.
5566-## Structure
66+## Current Configurations
7788-- flake.nix: Central file for exporting all my configs and anything else I need.
99-- lib.nix: Helper functions
1010-- systemconfigs/: All systems this flake configures, each system has some
1111- options that describe it but the main thing that determines what options they
1212- set are _roles_.
1313-- nixosModules/: A set of path-"routed" NixOS modules that represent "roles". A
1414- role is a feature a system can have (ex. the `graphics` role enables Hyprland,
1515- GUI apps, etc). Roles can either be a singular nix file, or a folder of them
1616- if they're complicated. Files named `role1+role2.nix` represent an _overlap_
1717- role, which is applied if all roles delimited by `+` are turned on.
1818-- base/: This folder contains modules applied unconditionally to all systems.
1919-- res/: Non-nix files used in the config. Pictures, scripts, etc.
2020-- pkgs/: Custom nix packages made for my config.
2121-- create-sys/: WIP tool for automating the creation of new systems. Currently
2222- just has an interactive prompt for adding a new `.nix` file to `systems/`.
2323-2424-## Implementation
2525-2626-I'm not going to lie, I have no idea what I'm doing. Is every feature here
2727-implmemented well? Definitely not, but that's okay!
88+- `aperture` - Framework 13 Laptop
99+- `black-mesa` - Desktop Computer w/ AMD GPU
1010+- `installer` - Installer/LiveCD ISO for my flake
···11-{lib, ...}: {
22- # /tmp should be clean!
33- boot.tmp.cleanOnBoot = true;
44-55- # Give me back my RAM!
66- services.logind.settings.Login.RuntimeDirectorySize = "100M";
77-}
-48
nixosModules/base/nix.nix
···11-{
22- pkgs,
33- inputs,
44- lib,
55- ...
66-}: {
77- environment.systemPackages = with pkgs; [
88- nh
99- nix-output-monitor
1010- comma-with-db
1111- ];
1212-1313- nix = {
1414- channel.enable = false;
1515- registry.p.flake = inputs.self;
1616- package = pkgs.lix;
1717- settings = {
1818- # So we can do `import <nixpkgs>`
1919- nix-path = "nixpkgs=${inputs.nixpkgs}";
2020- experimental-features = [
2121- "nix-command"
2222- "flakes"
2323- "pipe-operator"
2424- ];
2525- auto-optimise-store = true;
2626- fallback = true;
2727- };
2828- gc = {
2929- automatic = false;
3030- dates = "weekly";
3131- };
3232- };
3333-3434- # Switch ng is not as weird
3535- # system.switch = {
3636- # enable = false;
3737- # enableNg = true;
3838- # };
3939-4040- # Kill nix daemon builds over user sessions
4141- systemd.services.nix-daemon.serviceConfig.OOMScoreAdjust = lib.mkDefault 250;
4242-4343- # Keeps flake inputs when GCing
4444- system.extraDependencies = with builtins; let
4545- flakeDeps = flake: [flake.outPath] ++ (foldl' (a: b: a ++ b) [] (map flakeDeps (attrValues flake.inputs or {})));
4646- in
4747- flakeDeps inputs.self;
4848-}
-84
nixosModules/base/nushell.nix
···11-{
22- pkgs,
33- lib,
44- config,
55- ...
66-}: let
77- init-starship = pkgs.runCommand "starship-init" {} ''
88- ${pkgs.starship}/bin/starship init nu > $out
99- '';
1010- shellAliases = {
1111- cd = "z";
1212- sw = "zi";
1313- py = "python";
1414- cat = "bat";
1515- pcat = "prettybat";
1616- pbat = "prettybat";
1717- dog = "doggo";
1818- man = "__batman";
1919- bgrep = "batgrep";
2020- "🥺" = "sudo";
2121- };
2222- configFile.text = ''
2323- let fish_completer = {|spans|
2424- ${pkgs.fish}/bin/fish --command $'complete "--do-complete=($spans | str join " ")"'
2525- | $"value(char tab)description(char newline)" + $in
2626- | from tsv --flexible --no-infer
2727- }
2828- let zoxide_completer = {|spans|
2929- let query = $spans | skip 1
3030- let z_results = $query | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD}
3131- let l_results = fish_completer $spans
3232- $l_results | append $z_results
3333- }
3434- let multiple_completers = {|spans|
3535- # if the current command is an alias, get it's expansion
3636- let expanded_alias = (scope aliases | where name == $spans.0 | get -o 0 | get -o expansion)
3737-3838- # overwrite
3939-4040- let spans = (if $expanded_alias != null {
4141- # put the first word of the expanded alias first in the span
4242- $spans | skip 1 | prepend ($expanded_alias | split row " ")
4343- } else { $spans })
4444-4545- match $spans.0 {
4646- z => $zoxide_completer
4747- zi => $zoxide_completer
4848- __zoxide_z => $zoxide_completer
4949- __zoxide_zi => $zoxide_completer
5050- _ => $fish_completer
5151- } | do $in $spans
5252- }
5353-5454- let command_not_found = ${lib.fileContents ../../res/command_not_found.nu}
5555-5656- def --env __batman [...rest:string] {
5757- BAT_THEME="Monokai Extended" batman ...$rest
5858- }
5959-6060- $env.config = {
6161- show_banner: false
6262- completions: {
6363- external: {
6464- enable: true
6565- completer: $multiple_completers
6666- }
6767- }
6868- hooks: {
6969- command_not_found: $command_not_found
7070- }
7171- }
7272-7373- source ${init-starship}
7474- '';
7575-in {
7676- home-manager.users.bean.programs.nushell = {
7777- enable = true;
7878- inherit configFile shellAliases;
7979- };
8080- home-manager.users.root.programs.nushell = {
8181- enable = true;
8282- inherit configFile shellAliases;
8383- };
8484-}