diff --git a/nix/flake.lock b/nix/flake.lock index eac027b..0b74a57 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -30,12 +30,45 @@ "revCount": 473, "submodules": true, "type": "git", - "url": "https://github.com/keanuplayz/dotfiles" + "url": "https://github.com/lexisother/dotfiles" }, "original": { "submodules": true, "type": "git", - "url": "https://github.com/keanuplayz/dotfiles" + "url": "https://github.com/lexisother/dotfiles" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flakey-profile": { + "locked": { + "lastModified": 1712898590, + "narHash": "sha256-FhGIEU93VHAChKEXx905TSiPZKga69bWl1VB37FK//I=", + "owner": "lf-", + "repo": "flakey-profile", + "rev": "243c903fd8eadc0f63d205665a92d4df91d42d9d", + "type": "github" + }, + "original": { + "owner": "lf-", + "repo": "flakey-profile", + "type": "github" } }, "home-manager": { @@ -59,6 +92,43 @@ "type": "github" } }, + "lix": { + "inputs": { + "flake-utils": "flake-utils", + "flakey-profile": "flakey-profile", + "lix": "lix_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719353937, + "narHash": "sha256-86NBqDxAP20ET/UoKX0WvSItblNQ97czXb2q7lkMrwk=", + "ref": "refs/heads/main", + "rev": "5d9d94089fb1ca96222a34bfe245ef5c5ebefd37", + "revCount": 92, + "type": "git", + "url": "https://git.lix.systems/lix-project/nixos-module" + }, + "original": { + "type": "git", + "url": "https://git.lix.systems/lix-project/nixos-module" + } + }, + "lix_2": { + "flake": false, + "locked": { + "lastModified": 1718767907, + "narHash": "sha256-gpd+mGQxqVHw2kO6rSPQel8TkChHh9UpqxjsmQi0QJM=", + "rev": "85f282ef572577899b3d80ba8def1b920a386218", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/85f282ef572577899b3d80ba8def1b920a386218.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://git.lix.systems/lix-project/lix/archive/main.tar.gz" + } + }, "nixpkgs": { "locked": { "lastModified": 1720492477, @@ -80,8 +150,24 @@ "darwin": "darwin", "dotfiles": "dotfiles", "home-manager": "home-manager", + "lix": "lix", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/nix/flake.nix b/nix/flake.nix index 2d41a4f..cf246b6 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -4,26 +4,52 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin"; home-manager.url = "github:nix-community/home-manager/release-24.05"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - # nix will normally use the nixpkgs defined in home-managers inputs, we only want one copy of nixpkgs though darwin.url = "github:lnl7/nix-darwin"; - darwin.inputs.nixpkgs.follows = "nixpkgs"; # ... + lix.url = "git+https://git.lix.systems/lix-project/nixos-module"; dotfiles = { - url = "https://github.com/keanuplayz/dotfiles"; + url = "https://github.com/lexisother/dotfiles"; type = "git"; submodules = true; flake = false; }; + + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; + lix.inputs.nixpkgs.follows = "nixpkgs"; }; # add the inputs declared above to the argument attribute set - outputs = { self, nixpkgs, home-manager, dotfiles, darwin }: { + outputs = { self, nixpkgs, lix, home-manager, dotfiles, darwin }: let + system = "x86_64-darwin"; + importAll = path: map + (p: import (path + ("/" + p))) + (builtins.attrNames (builtins.readDir path)); + pkgs = import nixpkgs { + inherit system; + overlays = importAll ./overlays; + }; + libs = with builtins; listToAttrs (map + (path: { + name = replaceStrings [".nix"] [""] path; + value = (import (pkgs.lib.path.append ./lib path)) { inherit pkgs; }; + }) + (attrNames (readDir ./lib))); + in { darwinConfigurations."alymac" = darwin.lib.darwinSystem { - system = "x86_64-darwin"; - specialArgs = { inherit self; inherit dotfiles; }; + inherit system; + specialArgs = libs; modules = [ + ./system + lix.nixosModules.default home-manager.darwinModules.home-manager - ./hosts/alymac/default.nix + { + home-manager = { + extraSpecialArgs = { inherit self; inherit dotfiles; } // libs; + useGlobalPkgs = true; + useUserPackages = true; + users.alyxia.imports = [ ./home ]; + }; + } ]; }; }; diff --git a/nix/home/default.nix b/nix/home/default.nix new file mode 100644 index 0000000..14146e1 --- /dev/null +++ b/nix/home/default.nix @@ -0,0 +1,7 @@ +{ importAll, ... }: + +{ + imports = importAll [] ./.; + + home.stateVersion = "24.05"; +} diff --git a/nix/hosts/alymac/git.nix b/nix/home/git.nix similarity index 100% rename from nix/hosts/alymac/git.nix rename to nix/home/git.nix diff --git a/nix/hosts/alymac/nvim.nix b/nix/home/nvim.nix similarity index 100% rename from nix/hosts/alymac/nvim.nix rename to nix/home/nvim.nix diff --git a/nix/home/packages.nix b/nix/home/packages.nix new file mode 100644 index 0000000..8b7065a --- /dev/null +++ b/nix/home/packages.nix @@ -0,0 +1,93 @@ +{ pkgs, ... }: + +let + packageSets = with pkgs; { + system = [ + gnutls + gsasl + libtool + patchelf + pcre + pkg-config + ]; + + base = [ + act + bat + bitwarden-cli + cloudflared + delta + eza + ffmpeg + fzf + gh + git-crypt + gitui + gnupg + jq + kubectl + kubelogin-oidc + mosh + nixpkgs-fmt + pandoc + ripgrep + sops + stylua + texlive.combined.scheme-small + typst + vim + wget + + # Fyra + glib-networking + meson + ninja + vala + desktop-file-utils + ]; + + languages = [ + crystal + dhall + dhall-json + dhall-lsp-server + go + jdk + kotlin + kotlin-language-server + lua-language-server + nil + nodejs_20 + python2 + ruby_3_1 + sbcl + shards + zig + ]; + + programs = [ + rectangle + tailscale + ]; + + multimedia = [ + ffmpeg + ]; + + fonts = [ + nerdfonts + ibm-plex + ]; + + python = with python311Packages; [ + colorama + psutil + distro + ]; + }; + everything = builtins.concatLists (builtins.attrValues packageSets); + +in +{ + home.packages = everything; +} diff --git a/nix/hosts/alymac/zsh.nix b/nix/home/zsh.nix similarity index 83% rename from nix/hosts/alymac/zsh.nix rename to nix/home/zsh.nix index 702bb2a..777c0a6 100644 --- a/nix/hosts/alymac/zsh.nix +++ b/nix/home/zsh.nix @@ -10,8 +10,11 @@ [[ -d "$HOME/.local/bin" ]] || mkdir "$HOME/.local/bin" + export PATH="/Library/Developer/CommandLineTools/usr/bin:$PATH" export PATH="$PATH:$HOME/.local/bin" export PATH="$PATH:$HOME/.npm-packages/bin" + export PATH="$PATH:$HOME/.dotnet/tools" + export PATH="$PATH:$HOME/.config/composer/vendor/bin" export FRENYARD_SCALE=2.40 export RETHINK_API="https://rethink.alyxia.dev" export KUBECONFIG="$HOME/.kube/config.yaml" diff --git a/nix/hosts/alymac/default.nix b/nix/hosts/alymac/default.nix deleted file mode 100644 index 27733ea..0000000 --- a/nix/hosts/alymac/default.nix +++ /dev/null @@ -1,292 +0,0 @@ -{ self, pkgs, lib, dotfiles, ... }: - -with lib; -let - textEditor = "nvim"; - - packageSets = with pkgs; rec { - system = [ - gnutls - gsasl - libtool - patchelf - pcre - pkg-config - ]; - - base = [ - act - bat - bitwarden-cli - cloudflared - delta - eza - ffmpeg - fzf - gh - git-crypt - gitui - gnupg - jq - kubectl - kubelogin-oidc - mosh - nixpkgs-fmt - pandoc - ripgrep - sops - stylua - texlive.combined.scheme-small - typst - vim - wget - - # Fyra - glib-networking - meson - ninja - vala - desktop-file-utils - ]; - - languages = [ - crystal - dhall - dhall-json - dhall-lsp-server - go - jdk - kotlin - kotlin-language-server - lua-language-server - nil - nodejs_20 - python2 - ruby_3_1 - sbcl - shards - zig - ]; - - programs = [ - rectangle - tailscale - ]; - - multimedia = [ - ffmpeg - ]; - - fonts = [ - nerdfonts - ibm-plex - ]; - - python = with python311Packages; [ - colorama - psutil - distro - ]; - - everything = system ++ base ++ languages ++ programs ++ multimedia ++ fonts ++ python; - }; - - # Old solution kept for posterity {{{ - # We've got a small issue here. I tested this in a repl, and what I've - # observed is that listFilesRecursive spits out [ /full/path/to/default.nix ], - # while builtins.readDir spits out { "default.nix" = "regular"; } - # In theory, this shouldn't be much of an issue, however, when using readDir - # I would be able to do `map (n: "${./.}/${n}"), while when using - # listFilesRecursive I have to use `map (n: "${n}"). - # The difference here is that when using listFilesRecursive, `n` becomes - # `/nix/store/-default.nix`, meaning it can be used as-is, but when using - # `readDir` it becomes `default.nix`, meaning the string used in the map - # callback must be `"${./.}/${n}"` to get a path to the current derivation - # where the nix file lives in. - # Currently, I am unsure of the implications of having all files separately. - # To do it "the right way" I'd obviously prefer the nix files to be children - # of the alymac derivation, but it seems that if I want my map of imports to - # be generated from the entire directory listing, it isn't going to work out. - # The solution was slightly modified from this Reddit answer: - # - # importMap = map - # (n: "${n}") - # (lib.filesystem.listFilesRecursive ./.); - # importsFiltered = - # builtins.filter - # (x: !lib.strings.hasInfix "default" x) - # importMap; - # }}} - - getDir = dir: mapAttrs - (file: type: - if type == "directory" then getDir "${dir}/${file}" else type - ) - (builtins.readDir dir); - - files = dir: collect isString (mapAttrsRecursive - (path: type: concatStringsSep "/" path) - (getDir dir)); - - validFiles = dir: map - (file: ./. + "/${file}") - (filter - (file: hasSuffix ".nix" file && file != "default.nix") - (files dir)); - -in -{ - - nix = { - # package = pkgs.nix; - package = pkgs.lix.overrideAttrs (oldAttrs: { - postPatch = (oldAttrs.postPatch or "") + '' - substituteInPlace src/libmain/shared.cc \ - --replace-fail "(Lix, like Nix)" "but for lesbians" - ''; - }); - settings = { - experimental-features = [ "nix-command" "flakes" ]; - build-users-group = "nixbld"; - }; - gc = { - automatic = true; - options = "--delete-older-than 8d"; - }; - }; - - # Absolutely proprietary. - nixpkgs.config.allowUnfree = true; - nixpkgs.config.permittedInsecurePackages = [ - "python-2.7.18.8" - ]; - - # Make sure the nix daemon always runs - services.nix-daemon.enable = true; - - # enable the gpg agent by default - programs.gnupg.agent.enable = true; - - # if you use zsh (the default on new macOS installations), - # you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes - programs.zsh.enable = true; - - # tailscaled isn't automatically registered as a service that should run on installation. - services.tailscale.enable = true; - - # Make sure to set the correct values, or everything will break! (in reality, - # it will just not build) - users.users.alyxia = { - name = "alyxia"; - home = "/Users/alyxia"; - }; - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = { inherit self; inherit dotfiles; }; - users.alyxia = { pkgs, ... }: { - # Defined further above, generates a list of files to import. - imports = validFiles ./.; - - home = { - packages = packageSets.everything; - sessionVariables = { - EDITOR = textEditor; - }; - - file.".npmrc".text = '' - prefix = ''${HOME}/.npm-packages - ''; - }; - - # DO NOT CHANGE UNLESS YOU ARE ABSOLUTELY SURE ALL STATE AFFECTED BY THIS - # OPTION IS APPROPRIATELY MIGRATED!!! - home.stateVersion = "23.05"; # did you read the comment? - }; - }; - - homebrew = { - enable = true; - onActivation = { - autoUpdate = true; - cleanup = "zap"; - upgrade = true; - }; - - taps = [ - "drud/ddev" - "homebrew/cask-versions" - "int128/kubelogin" - ]; - - # Please do not the brew. - brews = [ - "bear" - "composer" - "croc" - "ddev" - "deno" - "dotnet" - "ferium" - "gradle" - "kubelogin" - "mkcert" - "nss" - "pinentry-mac" - "pkg-config" - "poetry" - "rustup" - "sdl2" - - # Fyra crap, but from Homebrew because someone doesn't know how to - # package libraries in nixpkgs - "appstream-glib" - "glib" - "gobject-introspection" - "gsettings-desktop-schemas" - "gtk4" - "gtksourceview5" - "libgee" - ]; - - casks = [ - "1password" - "1password-cli" - "alt-tab" - "android-studio" - "audacity" - "background-music" - "db-browser-for-sqlite" - "discord" - "discord-ptb" - "docker" - "firefox" - "firefox-developer-edition" - "goland" - "google-chrome" - "intellij-idea" - "itch" - "iterm2" - "lens" - "minecraft" - "obs" - "orbstack" - "phpstorm" - "plexamp" - "raycast" - "rider" - "rubymine" - "sequel-ace" - "shottr" - "slack" - "spotify" - "steam" - "texifier" - "thunderbird" - "transmit" - "visual-studio-code" - "wine-stable" - ]; - }; -} diff --git a/nix/lib/importAll.nix b/nix/lib/importAll.nix new file mode 100644 index 0000000..2db75b0 --- /dev/null +++ b/nix/lib/importAll.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: + +exclude: cwd: with builtins; with pkgs.lib; filter + (e: !elem e exclude) + (map + (p: path.append cwd p) + (attrNames (attrsets.filterAttrs + (p: t: + let + d = t == "directory"; + b = baseNameOf p; + in + d && pathExists (path.append cwd (p + "/default.nix")) || + !d && match ''.*\.nix'' b != null && b != "default.nix") + (readDir cwd)))) diff --git a/nix/overlays/lix.nix b/nix/overlays/lix.nix new file mode 100644 index 0000000..bde29b6 --- /dev/null +++ b/nix/overlays/lix.nix @@ -0,0 +1,8 @@ +(final: prev: { + lix = prev.lix.overrideAttrs (oldAttrs: { + postPatch = (oldAttrs.postPatch or "") + '' + substituteInPlace src/libmain/shared.cc \ + --replace-fail "(Lix, like Nix)" "but for lesbians" + ''; + }); +}) diff --git a/nix/system/default.nix b/nix/system/default.nix new file mode 100644 index 0000000..b5d51ba --- /dev/null +++ b/nix/system/default.nix @@ -0,0 +1,20 @@ +{ importAll, ... }: + +{ + imports = importAll [] ./.; + + users.users.alyxia = { + name = "alyxia"; + home = "/Users/alyxia"; + }; + + # enable the gpg agent by default + programs.gnupg.agent.enable = true; + + # if you use zsh (the default on new macOS installations), + # you'll need to enable this so nix-darwin creates a zshrc sourcing needed environment changes + programs.zsh.enable = true; + + # tailscaled isn't automatically registered as a service that should run on installation. + services.tailscale.enable = true; +} diff --git a/nix/system/homebrew.nix b/nix/system/homebrew.nix new file mode 100644 index 0000000..98446df --- /dev/null +++ b/nix/system/homebrew.nix @@ -0,0 +1,90 @@ +{ ... }: + +{ + homebrew = { + enable = true; + onActivation = { + autoUpdate = true; + cleanup = "zap"; + upgrade = true; + }; + + taps = [ + "drud/ddev" + "homebrew/cask-versions" + "int128/kubelogin" + ]; + + # Please do not the brew. + brews = [ + "bear" + "composer" + "croc" + "ddev" + "deno" + "dotnet" + "ferium" + "gradle" + "kubelogin" + "mkcert" + "nss" + "pinentry-mac" + "pkg-config" + "poetry" + "rustup" + "sdl2" + + # Fyra crap, but from Homebrew because someone doesn't know how to + # package libraries in nixpkgs + "appstream-glib" + "glib" + "gobject-introspection" + "gsettings-desktop-schemas" + "gtk4" + "gtksourceview5" + "libgee" + ]; + + casks = [ + "1password" + "1password-cli" + "alt-tab" + "android-studio" + "audacity" + "background-music" + "browserstacklocal" + "db-browser-for-sqlite" + "discord" + "discord-ptb" + "docker" + "firefox" + "firefox-developer-edition" + "goland" + "google-chrome" + "intellij-idea" + "itch" + "iterm2" + "lens" + "minecraft" + "obs" + "orbstack" + "phpstorm" + "plexamp" + "raycast" + "readdle-spark" + "rider" + "rubymine" + "sequel-ace" + "shottr" + "slack" + "spotify" + "steam" + "texifier" + "thunderbird" + "transmit" + "typora" + "visual-studio-code" + "wine-stable" + ]; + }; +} diff --git a/nix/system/nix.nix b/nix/system/nix.nix new file mode 100644 index 0000000..5bacbf3 --- /dev/null +++ b/nix/system/nix.nix @@ -0,0 +1,20 @@ +{ ... }: + +{ + services.nix-daemon.enable = true; + + nix = { + settings.experimental-features = [ "nix-command" "flakes" ]; + gc = { + automatic = true; + options = "--delete-older-than 8d"; + }; + }; + + nixpkgs = { + config = { + allowUnfree = true; + permittedInsecurePackages = [ "python-2.7.18.8" ]; + }; + }; +}