diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/darwin.nix b/darwin.nix index 71aa8bb..1d33df2 100644 --- a/darwin.nix +++ b/darwin.nix @@ -1,16 +1,5 @@ { config, lib, pkgs, ... }: -let - inherit (pkgs.stdenv.hostPlatform) isLinux; - inherit (pkgs.stdenv.hostPlatform) isDarwin; - - userName = builtins.getEnv "USER"; - homeDir = builtins.getEnv "HOME"; - - unstable = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; - pkgsUnstable = import unstable { config.allowUnfree = true; }; -in - { nix.settings.experimental-features = [ "flakes" @@ -31,17 +20,10 @@ in # $ darwin-rebuild changelog system.stateVersion = 4; - users.users.winston = { - name = userName; - home = homeDir; - shell = pkgs.zsh; - }; - homebrew = { enable = true; caskArgs.no_quarantine = true; onActivation = { - autoUpdate = true; cleanup = "zap"; }; casks = [ @@ -95,7 +77,7 @@ in }; yabai = { enable = true; - package = pkgsUnstable.yabai; + package = pkgs.unstable.yabai; extraConfig = let rule = "yabai -m rule --add"; ignored = app: builtins.concatStringsSep "\n" (map(e: "${rule} app=\"${e}\" manage=off sticky=off layer=above border=off") app); diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2dddf37 --- /dev/null +++ b/flake.lock @@ -0,0 +1,174 @@ +{ + "nodes": { + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673295039, + "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1675637696, + "narHash": "sha256-tilJS8zCS3PaDfVOfsBZ4zspuam8tc7IMZxtGa/K/uo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c43d4a3d6d9ef8ddbe2438362f5c775b4186000b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1675681488, + "narHash": "sha256-0E/oYpixC+joFk7UrY60TwZcdthzP2BXmJwne3Ni8ZI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "13fdd3945d8a2da5e4afe35d8a629193a9680911", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-22_05": { + "locked": { + "lastModified": 1656955776, + "narHash": "sha256-1aMu67m+orlGxVwfiX3RxTEVFoq/RmKa/L5u9zU3UNQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cc16da2c92041cbe817c40f62aac87c99104e9c2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1675698036, + "narHash": "sha256-BgsQkQewdlQi8gapJN4phpxkI/FCE/2sORBaFcYbp/A=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1046c7b92e908a1202c0f1ba3fc21d19e1cf1b62", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1656817495, + "narHash": "sha256-QEWkUBH4gu6ntNkF+9xIqDM22bto4PB+LSHIL6oWFpM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "db43c2a1ac04fdb1879f2fdca037fcd027a92dd5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nur": { + "locked": { + "lastModified": 1675748672, + "narHash": "sha256-zZ40cbNJuZMC00PNU99A2zxuv7xbMNc9EF5n5JRlt+k=", + "owner": "nix-community", + "repo": "NUR", + "rev": "19be7c1b5c06d36b510311f9c574de8897dbc50e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "NUR", + "type": "github" + } + }, + "root": { + "inputs": { + "darwin": "darwin", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "nur": "nur", + "sops": "sops" + } + }, + "sops": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "nixpkgs-22_05": "nixpkgs-22_05" + }, + "locked": { + "lastModified": 1675284668, + "narHash": "sha256-wJMCAr3GV8GXVWnDTf06QdZRwe6zp8oD/X6PdIWS8/I=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "9d523ff9cf0d9c3ad097443491fe7ed2187b17ed", + "type": "github" + }, + "original": { + "owner": "Mic92", + "ref": "feat/home-manager", + "repo": "sops-nix", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5bad27b --- /dev/null +++ b/flake.nix @@ -0,0 +1,92 @@ +{ + description = "nekowinston's hm flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + home-manager = { + url = "github:nix-community/home-manager/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nur.url = "github:nix-community/NUR/master"; + + sops.url = "github:Mic92/sops-nix/feat/home-manager"; + }; + + outputs = { + self, + darwin, + home-manager, + nixpkgs, + nixpkgs-unstable, + nur, + sops, + ... + }: + let + system = "aarch64-darwin"; + overlay-unstable = final: prev: { + unstable = import nixpkgs-unstable { + inherit system; + config.allowUnfree = true; + }; + }; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + # TODO: enable for NixOS + # nixosConfigurations = { + # "copium" = nixpkgs.lib.nixosSystem { + # system = "x86_64-linux"; + # modules = [ + # # make "pkgs.unstable" available + # ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-unstable ]; }) + # ./configuration.nix + # ]; + # }; + # }; + + darwinConfigurations = { + "sashimi-slicer" = darwin.lib.darwinSystem { + inherit system; + + modules = [ + ./darwin.nix + # make "pkgs.unstable" available + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ overlay-unstable ]; + }) + ]; + }; + }; + + homeConfigurations.winston = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + modules = [ + ./home.nix + sops.homeManagerModules.sops + nur.nixosModules.nur + ({ config, pkgs, ... }: { + nixpkgs.overlays = [ overlay-unstable ]; + }) + ]; + extraSpecialArgs = { + machine = { + username = "winston"; + homeDirectory = "/Users/winston"; + personal = true; + }; + }; + }; + }; +} diff --git a/home.nix b/home.nix index 06e8ccd..196e166 100644 --- a/home.nix +++ b/home.nix @@ -1,23 +1,12 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, machine, ... }: let - userName = builtins.getEnv "USER"; - homeDir = builtins.getEnv "HOME"; - inherit (pkgs.stdenv.hostPlatform) isLinux; inherit (pkgs.stdenv.hostPlatform) isDarwin; - - unstable = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; - pkgsUnstable = import unstable { config.allowUnfree = true; }; - - personalMachine = true; in { - nixpkgs.config.allowUnfree = true; - imports = [ - "${builtins.fetchTarball "https://github.com/Mic92/sops-nix/archive/feat/home-manager.tar.gz"}/modules/home-manager/sops.nix" ./catppuccin ./modules/firefox.nix ./modules/git.nix @@ -37,6 +26,8 @@ in ./modules/secrets.nix ]; + nixpkgs.config.allowUnfreePredicate = (pkg: true); + catppuccin = { defaultTheme = "mocha"; bat.enable = true; @@ -48,8 +39,8 @@ in manual.manpages.enable = false; home = { - username = userName; - homeDirectory = homeDir; + homeDirectory = machine.homeDirectory; + username = machine.username; packages = with pkgs; ([ zsh @@ -64,21 +55,21 @@ in (callPackage ./packages/python3.catppuccin-catwalk {}) (nerdfonts.override { fonts = ["NerdFontsSymbolsOnly"]; }) - pkgsUnstable.jetbrains.clion - pkgsUnstable.jetbrains.goland - pkgsUnstable.jetbrains.phpstorm - pkgsUnstable.jetbrains.pycharm-professional - pkgsUnstable.jetbrains.webstorm - pkgsUnstable.wezterm + pkgs.unstable.jetbrains.clion + pkgs.unstable.jetbrains.goland + pkgs.unstable.jetbrains.phpstorm + pkgs.unstable.jetbrains.pycharm-professional + pkgs.unstable.jetbrains.webstorm + pkgs.unstable.wezterm ] ++ lib.optionals isDarwin [ iina ] ++ lib.optionals isLinux [ _1password-gui insomnia mattermost-desktop - ] ++ lib.optionals (isLinux && personalMachine) [ + ] ++ lib.optionals (isLinux && machine.personal) [ (callPackage ./packages/python3.discover-overlay {}) - pkgsUnstable.discord + pkgs.unstable.discord lutris ]); @@ -112,8 +103,8 @@ in xdg = { enable = true; userDirs.enable = isLinux; - cacheHome = "${homeDir}/.cache"; - configHome = "${homeDir}/.config"; - dataHome = "${homeDir}/.local/share"; + cacheHome = "${machine.homeDirectory}/.cache"; + configHome = "${machine.homeDirectory}/.config"; + dataHome = "${machine.homeDirectory}/.local/share"; }; } diff --git a/justfile b/justfile new file mode 100644 index 0000000..2988653 --- /dev/null +++ b/justfile @@ -0,0 +1,21 @@ +switchcmd := if os() == "macos" { + "darwin-rebuild switch --flake ." +} else if os() == "linux" { + "nixos-rebuild switch --flake ." +} else { + "echo 'Unknown OS: {{os()}}'" +} + +secret_stage := "git add -f modules/secrets.nix" + +secret_unstage := "git restore --staged modules/secrets.nix" + +switch: + {{secret_stage}} + {{switchcmd}} + {{secret_unstage}} + +home: + {{secret_stage}} + home-manager switch --flake . + {{secret_unstage}} diff --git a/modules/firefox.nix b/modules/firefox.nix index ab73ba4..d0e69cf 100644 --- a/modules/firefox.nix +++ b/modules/firefox.nix @@ -6,13 +6,6 @@ let in { - # NUR for firefox addons - nixpkgs.config.packageOverrides = pkgs: { - nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { - inherit pkgs; - }; - }; - programs.firefox = { enable = true; # since I'm using firefox from brew on darwin, I need to build a dummy package @@ -21,7 +14,7 @@ in profiles.default = { search.default = "DuckDuckGo"; search.force = true; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + extensions = with config.nur.repos.rycee.firefox-addons; [ clearurls darkreader decentraleyes diff --git a/modules/neovim.nix b/modules/neovim.nix index fc08e5b..6ede21c 100644 --- a/modules/neovim.nix +++ b/modules/neovim.nix @@ -1,10 +1,5 @@ { config, pkgs, ... }: -let - unstable = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; - pkgsUnstable = import unstable { config.allowUnfree = true; }; -in - { home.sessionVariables = { EDITOR = "nvim"; @@ -62,7 +57,7 @@ in ltex-ls nodePackages.prettier rnix-lsp - pkgsUnstable.rust-analyzer + pkgs.unstable.rust-analyzer proselint rustc rustfmt diff --git a/modules/nvim/lazy-lock.json b/modules/nvim/lazy-lock.json index c7e25de..dd651c9 100644 --- a/modules/nvim/lazy-lock.json +++ b/modules/nvim/lazy-lock.json @@ -55,6 +55,7 @@ "telescope-project.nvim": { "branch": "master", "commit": "8e8ee37b7210761502cdf2c3a82b5ba8fb5b2972" }, "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, "todo-comments.nvim": { "branch": "main", "commit": "74c7d28cb50b0713c881ef69bcb6cdd77d8907d1" }, + "tree-sitter-just": { "branch": "main", "commit": "8af0aab79854aaf25b620a52c39485849922f766" }, "trouble.nvim": { "branch": "main", "commit": "490f7fe6d227f4f7a64f00be8c7dcd7a508ed271" }, "true-zen.nvim": { "branch": "main", "commit": "98740c76254c65576ec294551028b65081053588" }, "vim-astro": { "branch": "main", "commit": "34732be5e9a5c28c2409f4490edf92d46d8b55a9" }, diff --git a/modules/sketchybar.nix b/modules/sketchybar.nix index b1e71cb..5f5aa4f 100644 --- a/modules/sketchybar.nix +++ b/modules/sketchybar.nix @@ -1,20 +1,14 @@ { config, pkgs, lib, ... }: -let - # TODO: remove this once sketchybar is on unstable - pkgsUnstable = import {}; - inherit (pkgs.stdenv.hostPlatform) isDarwin; -in - { home = lib.mkIf isDarwin { - packages = [ pkgsUnstable.sketchybar ]; + packages = [ pkgs.unstable.sketchybar ]; }; launchd = lib.mkIf isDarwin { agents.sketchybar = { enable = true; config = { - ProgramArguments = [ "${lib.getExe pkgsUnstable.sketchybar}" ]; + ProgramArguments = [ "${lib.getExe pkgs.unstable.sketchybar}" ]; KeepAlive = true; RunAtLoad = true; ProcessType = "Interactive"; diff --git a/modules/zsh.nix b/modules/zsh.nix index 0c7ce1a..a9574ae 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, machine, ... }: { programs = { @@ -33,7 +33,7 @@ enableSyntaxHighlighting = true; initExtra = let - functionsDir = "${builtins.getEnv "HOME"}/${config.programs.zsh.dotDir}/functions"; + functionsDir = "${machine.homeDirectory}/${config.programs.zsh.dotDir}/functions"; in '' for conf in "${functionsDir}"/**/*.zsh; do diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7939edf --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +let pkgs = import {}; in + +pkgs.mkShell { + buildInputs = with pkgs; [ + just + ]; +}