My NixOS config Part 3: Flake-Parts Crusaders nix.ladas552.me
hjem nix nixos impermanence flake-parts nvfetcher niri noctalia

Added templates, and mermaid chart

Ladas552 a6bc9a4f 3f064512

+314
+30
README.md
··· 42 42 43 43 Also, I have [Norg document](./nix.norg), containing notes and TODO for the config, and folder `/docs` for containing more specific instructions. 44 44 45 + ## Directory structure 46 + 47 + ```mermaid 48 + flowchart TD 49 + flake[flake] --> A[docs] 50 + flake --> C[homeModules] 51 + flake --> F[hosts] 52 + flake --> N[nixosModules] 53 + flake --> R[overlays] 54 + flake --> T[pkgs] 55 + flake --> V[secrets] 56 + 57 + A -->|norg files with information| B[storage] 58 + C -->|directories containing config files| D[pkgs] 59 + C -->|importing all home-manager modules| E[default.nix] 60 + F --> G[all-my-hosts] 61 + G -->|custom iso for reinstalling| H[NixIso] 62 + G -->|nix-on-droid config| I[NixMux] 63 + G -->|acer laptop| J[NixPort] 64 + G -->|soon to be server| K[NixToks] 65 + G -->|experimenting host| L[NixVM] 66 + G -->|wsl for windows| M[NixWSL] 67 + N -->|importing all NixOS modules| O[default.nix] 68 + N -->|graphical sessions and WMs| P[Desktops] 69 + N -->|all other modules| Q[other modules] 70 + R -->|overlaying nixpkgs and applying patches| S[patches] 71 + T -->|scripts and neovim configs| U[derivations] 72 + V -->|try to decrypt it| W{secrets.yaml} 73 + ``` 74 + 45 75 ## Name 46 76 47 77 Yes, it is a [JoJo's reference](https://github.com/user-attachments/assets/7c467d52-a430-4bb3-9493-a5ffa0d69dd4)
+2
flake.nix
··· 214 214 }; 215 215 }; 216 216 packages = forAllSystems (commonArgs': (import ./pkgs commonArgs')); 217 + # flake templates 218 + templates = import ./templates; 217 219 }; 218 220 }
+10
templates/default.nix
··· 1 + { 2 + dioxus ={ 3 + path = ./dioxus; 4 + description = "Dioxus Rust devenv"; 5 + }; 6 + phoenix = { 7 + path = ./elixir-phoenix; 8 + description = "Elixir-Phoenix devenv with local package managment"; 9 + }; 10 + }
+1
templates/dioxus/.envrc
··· 1 + use flake . --no-pure-eval
+7
templates/dioxus/.gitignore
··· 1 + # Generated by Cargo 2 + # will have compiled files and executables 3 + /target 4 + .DS_Store 5 + 6 + # These are backup files generated by rustfmt 7 + **/*.rs.bk
+138
templates/dioxus/flake.nix
··· 1 + { 2 + description = "Experimental norg gui in dioxus"; 3 + # The whole flake is a mess 4 + inputs = { 5 + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable&shallow=1"; 6 + flake-utils.url = "github:numtide/flake-utils?shallow=1"; 7 + rust-overlay = { 8 + url = "github:oxalica/rust-overlay?shallow=1"; 9 + inputs.nixpkgs.follows = "nixpkgs"; 10 + }; 11 + }; 12 + 13 + outputs = 14 + { 15 + self, 16 + nixpkgs, 17 + rust-overlay, 18 + flake-utils, 19 + ... 20 + }: 21 + flake-utils.lib.eachDefaultSystem ( 22 + system: 23 + let 24 + overlays = [ (import rust-overlay) ]; 25 + pkgs = import nixpkgs { 26 + inherit system overlays; 27 + }; 28 + toolchain = pkgs.rustPlatform; 29 + cargoPackage = (pkgs.lib.importTOML "${self}/Cargo.toml").package; 30 + in 31 + rec { 32 + # nix build 33 + packages.default = toolchain.buildRustPackage { 34 + pname = cargoPackage.name; 35 + version = cargoPackage.version; 36 + src = pkgs.lib.cleanSource "${self}"; 37 + cargoLock = { 38 + lockFile = "${self}/Cargo.lock"; 39 + allowBuiltinFetchGit = true; 40 + }; 41 + useNextest = true; 42 + dontUseCargoParallelTests = true; 43 + 44 + nativeBuildInputs = with pkgs; [ 45 + pkg-config 46 + ]; 47 + buildInputs = with pkgs; [ 48 + openssl 49 + ]; 50 + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; 51 + 52 + meta = { 53 + description = cargoPackage.description; 54 + homepage = cargoPackage.repository; 55 + license = pkgs.lib.licenses.gpl2Only; 56 + maintainers = cargoPackage.authors; 57 + }; 58 + 59 + # For other makeRustPlatform features see: 60 + # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#cargo-features-cargo-features 61 + }; 62 + 63 + # nix run 64 + apps.default = flake-utils.lib.mkApp { drv = packages.default; }; 65 + 66 + # nix develop 67 + devShells.default = pkgs.mkShell { 68 + nativeBuildInputs = 69 + with pkgs; 70 + 71 + [ 72 + pkg-config 73 + gcc 74 + openssl 75 + rustPlatform.bindgenHook 76 + nodePackages.tailwindcss 77 + ]; 78 + buildInputs = 79 + with pkgs; 80 + let 81 + rustBuildInputs = 82 + [ 83 + pkgs.openssl 84 + pkgs.libiconv 85 + pkgs.pkg-config 86 + ] 87 + ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ 88 + pkgs.glib 89 + pkgs.gtk3 90 + pkgs.libsoup_3 91 + pkgs.webkitgtk_4_1 92 + pkgs.xdotool 93 + pkgs.cairo 94 + pkgs.gdk-pixbuf 95 + pkgs.gobject-introspection 96 + pkgs.atkmm 97 + pkgs.pango 98 + ] 99 + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin ( 100 + with pkgs.darwin.apple_sdk.frameworks; 101 + [ 102 + IOKit 103 + Carbon 104 + WebKit 105 + Security 106 + Cocoa 107 + ] 108 + ); 109 + in 110 + [ 111 + (pkgs.rust-bin.stable.latest.default.override { 112 + targets = [ 113 + "wasm32-unknown-unknown" 114 + "x86_64-unknown-linux-gnu" 115 + ]; 116 + }) 117 + # https://github.com/rust-lang/rust-analyzer/issues/18090 118 + # rust-bin.stable.latest.rust-analyzer 119 + rustBuildInputs 120 + cargo-edit 121 + cargo-nextest 122 + openssl 123 + # Dioxus dependency 124 + dioxus-cli 125 + lld 126 + wasm-bindgen-cli_0_2_100 127 + # Dioxus libraries 128 + 129 + ]; 130 + 131 + # Many editors rely on this rust-src PATH variable 132 + RUST_SRC_PATH = "${toolchain.rustLibSrc}"; 133 + 134 + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; 135 + }; 136 + } 137 + ); 138 + }
+1
templates/elixir-phoenix/.envrc
··· 1 + use flake . --no-pure-eval
+44
templates/elixir-phoenix/.gitignore
··· 1 + # The directory Mix will write compiled artifacts to. 2 + /_build/ 3 + 4 + # If you run "mix test --cover", coverage assets end up here. 5 + /cover/ 6 + 7 + # The directory Mix downloads your dependencies sources to. 8 + /deps/ 9 + 10 + # Where 3rd-party dependencies like ExDoc output generated docs. 11 + /doc/ 12 + 13 + # Ignore .fetch files in case you like to edit your project deps locally. 14 + /.fetch 15 + 16 + # If the VM crashes, it generates a dump, let's ignore it too. 17 + erl_crash.dump 18 + 19 + # Also ignore archive artifacts (built via "mix archive.build"). 20 + *.ez 21 + 22 + # Temporary files, for example, from tests. 23 + /tmp/ 24 + 25 + # Ignore package tarball (built via "mix hex.build"). 26 + wordle-*.tar 27 + 28 + # Ignore assets that are produced by build tools. 29 + /priv/static/assets/ 30 + 31 + # Ignore digested assets cache. 32 + /priv/static/cache_manifest.json 33 + 34 + # In case you use Node.js/npm, you want to ignore these. 35 + npm-debug.log 36 + /assets/node_modules/ 37 + 38 + # Database files 39 + *.db 40 + *.db-* 41 + 42 + # nix builds 43 + /.nix-hex/ 44 + /.nix-mix/
+81
templates/elixir-phoenix/flake.nix
··· 1 + { 2 + description = "Phoenix flake"; 3 + # The whole flake is a mess 4 + inputs = { 5 + nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; 6 + flake-utils.url = "github:numtide/flake-utils?shallow=1"; 7 + }; 8 + 9 + outputs = 10 + { 11 + self, 12 + nixpkgs, 13 + flake-utils, 14 + ... 15 + }: 16 + flake-utils.lib.eachDefaultSystem ( 17 + system: 18 + let 19 + pkgs = import nixpkgs { 20 + inherit system; 21 + }; 22 + in 23 + rec { 24 + # nix build 25 + packages.default = { }; 26 + 27 + # nix run 28 + apps.default = flake-utils.lib.mkApp { drv = packages.default; }; 29 + 30 + # nix develop 31 + devShells.default = pkgs.mkShell { 32 + nativeBuildInputs = with pkgs; [ 33 + ]; 34 + buildInputs = 35 + with pkgs; 36 + [ 37 + # elixir dependencies 38 + elixir 39 + elixir_ls # elixir lsp 40 + # erlang 41 + erlang_27 42 + erlang-ls # erlang lsp 43 + rebar3 # erlang built tool 44 + # database 45 + sqlite 46 + ] 47 + ++ lib.optionals stdenv.isLinux [ 48 + # For ExUnit Notifier on Linux. 49 + libnotify 50 + 51 + # For file_system on Linux. 52 + inotify-tools 53 + ] 54 + ++ lib.optionals stdenv.isDarwin ([ 55 + # For ExUnit Notifier on macOS. 56 + terminal-notifier 57 + 58 + # For file_system on macOS. 59 + darwin.apple_sdk.frameworks.CoreFoundation 60 + darwin.apple_sdk.frameworks.CoreServices 61 + ]); 62 + shellHook = '' 63 + # allows mix to work on the local directory 64 + mkdir -p .nix-mix 65 + mkdir -p .nix-hex 66 + export MIX_HOME=$PWD/.nix-mix 67 + export HEX_HOME=$PWD/.nix-hex 68 + export ERL_LIBS=$HEX_HOME/lib/erlang/lib 69 + 70 + # concats PATH 71 + export PATH=$MIX_HOME/bin:$PATH 72 + export PATH=$MIX_HOME/escripts:$PATH 73 + export PATH=$HEX_HOME/bin:$PATH 74 + 75 + # enables history for IEx 76 + export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"$PWD/.erlang-history\"'" 77 + ''; 78 + }; 79 + } 80 + ); 81 + }