diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74af16e..8faa4b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,8 +6,9 @@ jobs: fail-fast: false matrix: configuration: - - "nixosConfigurations.x86_64-linux.volt-nixos.config.system.build.toplevel" - - "nixosConfigurations.x86_64-linux.zephyr-nixos.config.system.build.toplevel" + - "nixosConfigurations.volt-nixos.config.system.build.toplevel" + - "nixosConfigurations.zephyr-nixos.config.system.build.toplevel" + - 'darwinConfigurations.work-macbook.system' runs-on: ubuntu-latest diff --git a/common/apps.nix b/common/apps.nix new file mode 100644 index 0000000..a97cd27 --- /dev/null +++ b/common/apps.nix @@ -0,0 +1,9 @@ +{ pkgs, pkgs-unstable, ... }: + +{ + home.packages = [ + pkgs.obsidian + pkgs-unstable.discord + pkgs-unstable.spotify + ]; +} diff --git a/common/home-manager.nix b/common/home-manager.nix index 1eac83e..6166dde 100644 --- a/common/home-manager.nix +++ b/common/home-manager.nix @@ -1,23 +1,24 @@ { - imports = map (x: ../components + x) [ - /alacritty.nix - /cli.nix - /code.nix - /common-apps.nix - /cpp.nix - /dotnet.nix - /gcloud.nix - /git.nix - /haskell.nix - /tex.nix - /tmux.nix - /typst.nix - /vim.nix - /zsh.nix - ]; + imports = + [ ./apps.nix ] + ++ map (x: ../components + x) [ + /alacritty.nix + /android.nix + /cli.nix + /code.nix + /databases.nix + /dotnet.nix + /gcloud.nix + /git.nix + /java.nix + /tex.nix + /tmux.nix + /typst.nix + /vim.nix + /zsh.nix + ]; home.username = "jeremy"; - home.homeDirectory = "/home/jeremy"; home.stateVersion = "23.05"; programs.home-manager.enable = true; diff --git a/common/nixos-home-manager.nix b/common/nixos-home-manager.nix index ca400c5..9c298e7 100644 --- a/common/nixos-home-manager.nix +++ b/common/nixos-home-manager.nix @@ -5,11 +5,14 @@ let in { imports = map (x: ../components + x) [ - /android.nix - /databases.nix + /common-apps.nix + /cpp.nix + /haskell.nix /web.nix ]; + home.homeDirectory = "/home/jeremy"; + programs.git.extraConfig = { commit.gpgsign = true; user.signingkey = publicKey; diff --git a/components/android.nix b/components/android.nix index f48dab1..d22ac90 100644 --- a/components/android.nix +++ b/components/android.nix @@ -1,8 +1,7 @@ { pkgs, pkgs-unstable, ... }: { - home.packages = with pkgs; [ - android-tools - pkgs-unstable.android-studio - ]; + home.packages = + with pkgs; + [ android-tools ] ++ lib.optional (!stdenv.isDarwin) [ pkgs-unstable.android-studio ]; } diff --git a/components/cli.nix b/components/cli.nix index 16e20ff..e203258 100644 --- a/components/cli.nix +++ b/components/cli.nix @@ -1,36 +1,41 @@ { pkgs, pkgs-unstable, ... }: { - home.packages = with pkgs; [ - asciinema - bat - caddy - delta - dogdns - du-dust - entr - fd - ffmpeg-full - file - miller - multipath-tools - ngrok - nmap - nodePackages.svgo - ocrmypdf - ollama - pdftk - pkgs-unstable.nixfmt-rfc-style - ranger - ripgrep - tesseract - tokei - tree - units - wol - yt-dlp - zip - ]; + home.packages = + with pkgs; + [ + asciinema + bat + caddy + delta + dogdns + du-dust + entr + fd + ffmpeg-full + file + mani + miller + nmap + nodePackages.svgo + ocrmypdf + ollama + pdftk + pkgs-unstable.nixfmt-rfc-style + ranger + ripgrep + tesseract + tokei + tree + units + yt-dlp + zip + ] + ++ lib.optional (!stdenv.isDarwin) [ + multipath-tools + ngrok + wol + ]; programs.bat.enable = true; programs.jq.enable = true; diff --git a/components/databases.nix b/components/databases.nix index 2918c7a..16d0df2 100644 --- a/components/databases.nix +++ b/components/databases.nix @@ -1,11 +1,13 @@ { pkgs, ... }: { - home.packages = with pkgs; [ - postgresql - sqlite - jetbrains.datagrip - ]; + home.packages = + with pkgs; + [ + postgresql + sqlite + ] + ++ lib.optional (!stdenv.isDarwin) [ jetbrains.datagrip ]; home.file.".psqlrc".text = '' \set ON_ERROR_ROLLBACK interactive diff --git a/components/dotnet.nix b/components/dotnet.nix index d8a3477..9c5db7e 100644 --- a/components/dotnet.nix +++ b/components/dotnet.nix @@ -13,6 +13,6 @@ pkgs-unstable.dotnet-sdk_8 pkgs-unstable.dotnet-aspnetcore_8 ]) - pkgs-unstable.jetbrains.rider - ]; + ] + ++ lib.optional (!stdenv.isDarwin) [ pkgs-unstable.jetbrains.rider ]; } diff --git a/components/java.nix b/components/java.nix new file mode 100644 index 0000000..ec2590f --- /dev/null +++ b/components/java.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +{ + programs.java = { + enable = true; + package = pkgs.openjdk17; + }; +} diff --git a/components/vim.nix b/components/vim.nix index 5b0270e..ed6f361 100644 --- a/components/vim.nix +++ b/components/vim.nix @@ -12,6 +12,7 @@ catppuccin-nvim fzf-vim kotlin-vim + nerdtree vim-commentary vim-fugitive vim-nix diff --git a/darwin-home-manager.nix b/darwin-home-manager.nix new file mode 100644 index 0000000..7f07156 --- /dev/null +++ b/darwin-home-manager.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: + +{ + home.packages = with pkgs; [ + bundler + element-desktop + iterm2 + kitty + xcodes + ]; + + home.homeDirectory = "/Users/jeremy"; +} diff --git a/flake.lock b/flake.lock index 94fc47b..86b9c28 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "cl-nix-lite": { + "locked": { + "lastModified": 1717972076, + "narHash": "sha256-hnZEsDInTcsVSL5LBGDAZegAxVLBus/wiJh+sNM15zU=", + "owner": "hraban", + "repo": "cl-nix-lite", + "rev": "cc920bfb0a6402d3871f470c98d65266126973e4", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "cl-nix-lite", + "type": "github" + } + }, "color-scheme-sync": { "inputs": { "crane": "crane", @@ -46,6 +61,27 @@ "type": "github" } }, + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718345812, + "narHash": "sha256-FJhA+YFsOFrAYe6EaiTEfomNf7jeURaPiG5/+a3DRSc=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "ff988d78f2f55641efacdf9a585d2937f7e32a9b", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -62,6 +98,23 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1697816753, + "narHash": "sha256-40to80AEIyKCQI0xMKCeF5ePoIKTYgjVVCZeu4CnTxM=", + "owner": "hraban", + "repo": "flake-compat", + "rev": "6025bade1336a36014639bc3f67eacc853dab78f", + "type": "github" + }, + "original": { + "owner": "hraban", + "ref": "fixed-output", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -98,6 +151,23 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -119,19 +189,40 @@ "type": "github" } }, + "mac-app-util": { + "inputs": { + "cl-nix-lite": "cl-nix-lite", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1718336101, + "narHash": "sha256-ynZTySa2iTry8be1NZMrnDoya1vZBfM3chBzHNHEYZw=", + "owner": "hraban", + "repo": "mac-app-util", + "rev": "a3873969fc0198b308881cbd9a1863e6ca429f26", + "type": "github" + }, + "original": { + "owner": "hraban", + "repo": "mac-app-util", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1717281328, - "narHash": "sha256-evZPzpf59oNcDUXxh2GHcxHkTEG4fjae2ytWP85jXRo=", - "owner": "nixos", + "lastModified": 1717868076, + "narHash": "sha256-c83Y9t815Wa34khrux81j8K8ET94ESmCuwORSKm2bQY=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "b3b2b28c1daa04fe2ae47c21bb76fd226eac4ca1", + "rev": "cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-24.05", + "owner": "NixOS", "repo": "nixpkgs", + "rev": "cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9", "type": "github" } }, @@ -150,12 +241,30 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717281328, + "narHash": "sha256-evZPzpf59oNcDUXxh2GHcxHkTEG4fjae2ytWP85jXRo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b3b2b28c1daa04fe2ae47c21bb76fd226eac4ca1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "color-scheme-sync": "color-scheme-sync", + "darwin": "darwin", "flake-utils": "flake-utils_2", "home-manager": "home-manager", - "nixpkgs": "nixpkgs", + "mac-app-util": "mac-app-util", + "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable" } }, @@ -215,6 +324,21 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "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/flake.nix b/flake.nix index 95ad31f..0806150 100644 --- a/flake.nix +++ b/flake.nix @@ -19,57 +19,119 @@ url = "github:bash/color-scheme-sync"; inputs.nixpkgs.follows = "nixpkgs"; }; + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + mac-app-util = { + url = "github:hraban/mac-app-util"; + # This does not work due to broken packages + # inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs: - let - system = "x86_64-linux"; - config = { - allowUnfree = true; - input-fonts.acceptLicense = true; - }; - pkgs = import inputs.nixpkgs { inherit system config; }; - pkgs-unstable = import inputs.nixpkgs-unstable { inherit system config; }; - nixosConfig = - { - nixosModule, - homeManagerModule ? { }, - }: - inputs.nixpkgs.lib.nixosSystem { - specialArgs = { - inherit pkgs pkgs-unstable; + { + nixosConfigurations = + let + system = "x86_64-linux"; + config = { + allowUnfree = true; + input-fonts.acceptLicense = true; }; - modules = [ - ./common/nixos.nix - nixosModule - inputs.color-scheme-sync.nixosModules.default - inputs.home-manager.nixosModules.home-manager + pkgs = import inputs.nixpkgs { inherit system config; }; + pkgs-unstable = import inputs.nixpkgs-unstable { inherit system config; }; + nixosConfig = { - home-manager.users.jeremy.imports = [ - ./common/home-manager.nix - ./common/nixos-home-manager.nix - homeManagerModule - ]; - home-manager.useGlobalPkgs = true; - home-manager.extraSpecialArgs = { - inherit pkgs-unstable; + nixosModule, + homeManagerModule ? { }, + }: + inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit pkgs pkgs-unstable; }; - } - ]; + modules = [ + ./common/nixos.nix + nixosModule + inputs.color-scheme-sync.nixosModules.default + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.jeremy.imports = [ + ./common/home-manager.nix + ./common/nixos-home-manager.nix + homeManagerModule + ]; + home-manager.useGlobalPkgs = true; + home-manager.extraSpecialArgs = { + inherit pkgs-unstable; + }; + } + ]; + }; + in + { + "volt-nixos" = nixosConfig { + nixosModule = ./volt/nixos-configuration.nix; + homeManagerModule = ./volt/home-manager.nix; + }; + + "zephyr-nixos" = nixosConfig { + nixosModule = ./zephyr/nixos-configuration.nix; + }; }; - in - { - nixosConfigurations."volt-nixos" = nixosConfig { - nixosModule = ./volt/nixos-configuration.nix; - homeManagerModule = ./volt/home-manager.nix; - }; - nixosConfigurations."zephyr-nixos" = nixosConfig { - nixosModule = ./zephyr/nixos-configuration.nix; - }; + darwinConfigurations = + let + system = "x86_64-darwin"; + config = { + allowUnfree = true; + input-fonts.acceptLicense = true; + }; + pkgs = import inputs.nixpkgs { inherit system config; }; + pkgs-unstable = import inputs.nixpkgs-unstable { inherit system config; }; + in + { + "work-macbook" = inputs.darwin.lib.darwinSystem { + inherit system; + + modules = [ + { + nix.useDaemon = true; + nix.settings = { + trusted-users = [ "jeremy" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + + nixpkgs.config = config; + environment.shells = [ pkgs.zsh ]; + programs.zsh.enable = true; + users.users.jeremy.home = "/Users/jeremy"; + fonts.fonts = [ pkgs.jetbrains-mono ]; + } + inputs.home-manager.darwinModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.jeremy.imports = [ + ./common/home-manager.nix + ./darwin-home-manager.nix + ]; + extraSpecialArgs = { + inherit pkgs-unstable; + }; + sharedModules = [ inputs.mac-app-util.homeManagerModules.default ]; + }; + } + ]; + }; + }; } // inputs.flake-utils.lib.eachDefaultSystem (system: { - formatter = pkgs-unstable.nixfmt-rfc-style; + formatter = inputs.nixpkgs-unstable.legacyPackages.${system}.nixfmt-rfc-style; }); }