From f4678f910f051da28708eac2f07a8c2ae5a31c22 Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Sat, 20 Aug 2022 21:45:49 +0100 Subject: [PATCH] General faff (#9) --- VsCodeExtensions/Program.fs | 4 +- darwin-configuration.nix | 27 +++++------ flake.lock | 63 ++++++++++++++++++++------ flake.nix | 56 +++++++++++++---------- home.nix | 89 ++++++++++++++++++------------------- python.nix | 28 ++++++------ rider/default.nix | 74 +++++++++++++++--------------- ssh.config | 2 +- vscode-extensions.nix | 26 +++++------ 9 files changed, 203 insertions(+), 166 deletions(-) diff --git a/VsCodeExtensions/Program.fs b/VsCodeExtensions/Program.fs index 623bc1b..9161c5f 100644 --- a/VsCodeExtensions/Program.fs +++ b/VsCodeExtensions/Program.fs @@ -81,14 +81,14 @@ type NixFile = static member Parse (s : string) : NixFile = let pre, post = - s.Split "\n] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [\n" + s.Split "++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [" |> function | [| pre ; post |] -> pre, post | _ -> failwith "Unexpected number of '++'" let verbatim, skipped = match pre.Split "\n" |> List.ofArray with - | "{ pkgs }:" :: "" :: "with pkgs.vscode-extensions; [" :: rest -> + | "{pkgs}:" :: "with pkgs.vscode-extensions;" :: " [" :: rest -> rest |> List.map (fun s -> if s.StartsWith '#' then Choice2Of2 (s.[2..].Trim()) else Choice1Of2 (s.Trim()) diff --git a/darwin-configuration.nix b/darwin-configuration.nix index 7918222..3b792c2 100644 --- a/darwin-configuration.nix +++ b/darwin-configuration.nix @@ -1,22 +1,18 @@ -{ pkgs, ... }: - -let python = import ./python.nix { inherit pkgs; }; in - -{ +{pkgs, ...}: let + python = import ./python.nix {inherit pkgs;}; +in { nix.useDaemon = true; # List packages installed in system profile. To search by name, run: # $ nix-env -qaP | grep wget - environment.systemPackages = - [ - pkgs.alacritty - pkgs.rustup - pkgs.libiconv - pkgs.clang - #pkgs.keepassxc - python - ]; + environment.systemPackages = [ + pkgs.alacritty + pkgs.rustup + pkgs.libiconv + pkgs.clang + python + ]; # This line is required; otherwise, on shell startup, you won't have Nix stuff in the PATH. programs.zsh.enable = true; @@ -35,9 +31,10 @@ let python = import ./python.nix { inherit pkgs; }; in nix.extraOptions = '' auto-optimise-store = true - experimental-features = nix-command flakes + experimental-features = nix-command flakes ca-derivations max-jobs = auto # Allow building multiple derivations in parallel keep-outputs = true # Do not garbage-collect build time-only dependencies (e.g. clang) + keep-derivations = true # Allow fetching build results from the Lean Cachix cache trusted-substituters = https://lean4.cachix.org/ trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= lean4.cachix.org-1:mawtxSxcaiWE24xCXXgh3qnvlTkyU7evRRnGeAhD4Wk= diff --git a/flake.lock b/flake.lock index 110fa53..44816ac 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1645293039, - "narHash": "sha256-PwdDu+SkX8dreeuJ/4av1sEluNZdrpdXv8JsRKKg1Yc=", + "lastModified": 1657835815, + "narHash": "sha256-CnZszAYpNKydh6N7+xg+eRtWNVoAAGqc6bg+Lpgq1xc=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "1df878b6f8351795a3bebfbe4fd2d02e1e8b29d6", + "rev": "54a24f042f93c79f5679f133faddedec61955cf2", "type": "github" }, "original": { @@ -22,12 +22,18 @@ } }, "emacs": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1646559142, - "narHash": "sha256-8PClYIjlkBKsl4hYWMtCGRrbaF127XJB6dtfS8gxTGc=", + "lastModified": 1659035460, + "narHash": "sha256-zU8fxINFH9EHSMuIrSjkD8Oy6Rr9vp2ek1py97fe0tk=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "0949bcda488e28eab931e7be99400ad5f0094128", + "rev": "962851d3e66ce26c65693ab9e2eadd87c24b5c7c", "type": "github" }, "original": { @@ -36,18 +42,34 @@ "type": "github" } }, + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ "nixpkgs" - ] + ], + "utils": "utils" }, "locked": { - "lastModified": 1646559628, - "narHash": "sha256-WDoqxH/IPTV8CkI15wwzvXYgXq9UPr8xd8WKziuaynw=", + "lastModified": 1658924727, + "narHash": "sha256-Fhh9FK9CvuCLxG1WkWJPoendDeXKI4gHYTfezo1n2Zg=", "owner": "nix-community", "repo": "home-manager", - "rev": "afe96e7433c513bf82375d41473c57d1f66b4e68", + "rev": "0e2f7876d2f2ae98a67d89a8bef8c49332aae5af", "type": "github" }, "original": { @@ -58,11 +80,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1646470760, - "narHash": "sha256-dQISyucVCCPaFioUhy5ZgfBz8rOMKGI8k13aPDFTqEs=", + "lastModified": 1658937758, + "narHash": "sha256-FxQB/tWX15Faq3GBM+qTfVzd9qJqy/3CEgBp2zpHeNc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1fc7212a2c3992eedc6eedf498955c321ad81cc2", + "rev": "8f73de28e63988da02426ebb17209e3ae07f103b", "type": "github" }, "original": { @@ -79,6 +101,21 @@ "home-manager": "home-manager", "nixpkgs": "nixpkgs" } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 61046d0..4080ba0 100644 --- a/flake.nix +++ b/flake.nix @@ -17,30 +17,38 @@ }; }; - outputs = { self, darwin, emacs, nixpkgs, home-manager, ... }@inputs: - let system = "aarch64-darwin"; in - let config = { - allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ - "vscode" - ]; - }; in - let overlays = [ emacs.overlay ] ++ import ./overlays.nix; in - let pkgs = (import nixpkgs { inherit system config overlays; }); in - { - darwinConfigurations = { - nixpkgs = pkgs; - patrick = darwin.lib.darwinSystem { - system = system; - modules = [ - ./darwin-configuration.nix - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.Patrick = import ./home.nix { nixpkgs = pkgs; }; - } - ]; - }; + outputs = { + self, + darwin, + emacs, + nixpkgs, + home-manager, + ... + } @ inputs: let + system = "aarch64-darwin"; + in let + config = { + #contentAddressedByDefault = true; + }; + in let + overlays = [emacs.overlay] ++ import ./overlays.nix; + in let + pkgs = import nixpkgs {inherit system config overlays;}; + in { + darwinConfigurations = { + nixpkgs = pkgs; + patrick = darwin.lib.darwinSystem { + system = system; + modules = [ + ./darwin-configuration.nix + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.Patrick = import ./home.nix {nixpkgs = pkgs;}; + } + ]; }; }; + }; } diff --git a/home.nix b/home.nix index c33dff3..1efedc0 100644 --- a/home.nix +++ b/home.nix @@ -1,8 +1,4 @@ -{ - nixpkgs, - ... -}: -let +{nixpkgs, ...}: let username = "Patrick"; in let dotnet = nixpkgs.dotnet-sdk_6; @@ -32,43 +28,44 @@ in { # changes in each release. home.stateVersion = "22.05"; - home.packages = - [ - nixpkgs.rust-analyzer - nixpkgs.tmux - nixpkgs.wget - nixpkgs.youtube-dl - nixpkgs.yt-dlp - nixpkgs.cmake - nixpkgs.gnumake - nixpkgs.gcc - nixpkgs.gdb - nixpkgs.hledger - nixpkgs.hledger-web - dotnet - nixpkgs.docker - nixpkgs.jitsi-meet - #nixpkgs.handbrake - nixpkgs.ripgrep - nixpkgs.elan - nixpkgs.coreutils-prefixed - nixpkgs.shellcheck - nixpkgs.html-tidy - nixpkgs.hugo - #nixpkgs.agda - nixpkgs.pijul - nixpkgs.universal-ctags - nixpkgs.asciinema - nixpkgs.git-lfs - nixpkgs.imagemagick - nixpkgs.nixpkgs-fmt - nixpkgs.rnix-lsp - ]; + home.packages = [ + # Broken on Apple Silicon + #nixpkgs.keepassxc + nixpkgs.rust-analyzer + nixpkgs.tmux + nixpkgs.wget + nixpkgs.youtube-dl + nixpkgs.yt-dlp + nixpkgs.cmake + nixpkgs.gnumake + nixpkgs.gcc + nixpkgs.gdb + nixpkgs.hledger + nixpkgs.hledger-web + dotnet + nixpkgs.docker + nixpkgs.jitsi-meet + #nixpkgs.handbrake + nixpkgs.ripgrep + nixpkgs.elan + nixpkgs.coreutils-prefixed + nixpkgs.shellcheck + nixpkgs.html-tidy + nixpkgs.hugo + #nixpkgs.agda + nixpkgs.pijul + nixpkgs.universal-ctags + nixpkgs.asciinema + nixpkgs.git-lfs + nixpkgs.imagemagick + nixpkgs.nixpkgs-fmt + nixpkgs.rnix-lsp + ]; programs.vscode = { enable = true; - package = nixpkgs.vscode; - extensions = import ./vscode-extensions.nix { pkgs = nixpkgs; }; + package = nixpkgs.vscodium; + extensions = import ./vscode-extensions.nix {pkgs = nixpkgs;}; userSettings = { workbench.colorTheme = "Default High Contrast"; "files.Exclude" = { @@ -81,9 +78,11 @@ in { "git.path" = "${nixpkgs.git}/bin/git"; "update.mode" = "none"; "docker.dockerPath" = "${nixpkgs.docker}/bin/docker"; - #"lean.leanpkgPath" = "/Users/${username}/.elan/toolchains/stable/bin/leanpkg"; - "lean.executablePath" = "/Users/${username}/.elan/toolchains/lean4/bin/lean"; - "lean.memoryLimit" = 8092; + "lean.leanpkgPath" = "/Users/${username}/.elan/toolchains/stable/bin/leanpkg"; + "lean.executablePath" = "/Users/${username}/.elan/toolchains/stable/bin/lean"; + #"lean.executablePath" = "/Users/${username}/.elan/toolchains/lean4/bin/lean"; + "explorer.confirmDelete" = false; + "lean.memoryLimit" = 16384; "latex-workshop.view.pdf.viewer" = "tab"; }; }; @@ -161,7 +160,7 @@ in { twohead = "ort"; }; merge = { - conflictStyle = "zdiff3"; + conflictStyle = "diff3"; }; diff = { colorMoved = "default"; @@ -208,8 +207,8 @@ in { home.file.".config/yt-dlp/config".source = ./youtube-dl.conf; programs.emacs = { enable = true; - package = nixpkgs.emacsGcc; - extraPackages = (epkgs: []); + package = nixpkgs.emacsNativeComp; + extraPackages = epkgs: []; extraConfig = '' (load-file (let ((coding-system-for-read 'utf-8)) (shell-command-to-string "agda-mode locate"))) diff --git a/python.nix b/python.nix index 0781c98..b08f40c 100644 --- a/python.nix +++ b/python.nix @@ -1,16 +1,14 @@ -{ pkgs }: - -let my-python-packages = python-packages: with python-packages; [ - pip - mathlibtools -]; +{pkgs}: let + my-python-packages = python-packages: + with python-packages; [ + pip + mathlibtools + ]; +in let + packageOverrides = self: super: { + # Test failures on darwin ("windows-1252"); just skip pytest + # (required for elan) + beautifulsoup4 = super.beautifulsoup4.overridePythonAttrs (old: {pytestCheckPhase = "true";}); + }; in - -let packageOverrides = self: super: { - # Test failures on darwin ("windows-1252"); just skip pytest - # (required for elan) - beautifulsoup4 = super.beautifulsoup4.overridePythonAttrs (old: { pytestCheckPhase = "true"; }); -}; -in - -(pkgs.python3.override { inherit packageOverrides; }).withPackages my-python-packages + (pkgs.python3.override {inherit packageOverrides;}).withPackages my-python-packages diff --git a/rider/default.nix b/rider/default.nix index b19f17b..9f2c28e 100644 --- a/rider/default.nix +++ b/rider/default.nix @@ -1,44 +1,48 @@ -{ pkgs, config, lib, ... }: - -let src = ./GlobalSettingsStorage.DotSettings; in -let link = ./link.sh; in - -let riderconfig = - pkgs.stdenv.mkDerivation { - name = "rider-config"; - version = "2021.2"; - - src = src; - phases = [ "unpackPhase" ]; - unpackPhase = '' - mkdir -p "$out" - cp ${src} "$out/GlobalSettingsStorage.DotSettings" - cp ${link} "$out/link.sh" - chmod u+x "$out/link.sh" - sed -i 's_NIX-DOTNET-SDK_${config.rider.dotnet}_' "$out/GlobalSettingsStorage.DotSettings" - sed -i "s!NIX-RIDER-CONFIG!$out!" "$out/link.sh" - ''; - - installPhase = '' - ''; - }; -in - { + pkgs, + config, + lib, + ... +}: let + src = ./GlobalSettingsStorage.DotSettings; +in let + link = ./link.sh; +in let + riderconfig = pkgs.stdenv.mkDerivation { + name = "rider-config"; + version = "2021.2"; + + src = src; + phases = ["unpackPhase"]; + unpackPhase = '' + mkdir -p "$out" + cp ${src} "$out/GlobalSettingsStorage.DotSettings" + cp ${link} "$out/link.sh" + chmod u+x "$out/link.sh" + sed -i 's_NIX-DOTNET-SDK_${config.rider.dotnet}_' "$out/GlobalSettingsStorage.DotSettings" + sed -i "s!NIX-RIDER-CONFIG!$out!" "$out/link.sh" + ''; + + installPhase = '' + ''; + }; +in { options = { - rider.enable = lib.mkOption { default = false; }; - rider.username = lib.mkOption { type = lib.types.str; example = "Patrick"; }; - rider.dotnet = lib.mkOption { default = pkgs.dotnet-sdk; }; + rider.enable = lib.mkOption {default = false;}; + rider.username = lib.mkOption { + type = lib.types.str; + example = "Patrick"; + }; + rider.dotnet = lib.mkOption {default = pkgs.dotnet-sdk;}; }; config = lib.mkIf config.rider.enable { - home.activation.jetbrains-rider-settings = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + home.activation.jetbrains-rider-settings = lib.hm.dag.entryAfter ["writeBoundary"] '' -dest="/Users/${config.rider.username}/Library/Application Support/JetBrains" -if [ -e "$dest" ]; then - find "$dest" -maxdepth 1 -type d -name 'Rider*' -exec sh -c '${riderconfig}/link.sh "$0"' {} \; -fi + dest="/Users/${config.rider.username}/Library/Application Support/JetBrains" + if [ -e "$dest" ]; then + find "$dest" -maxdepth 1 -type d -name 'Rider*' -exec sh -c '${riderconfig}/link.sh "$0"' {} \; + fi ''; }; - } diff --git a/ssh.config b/ssh.config index 413e531..909f4ad 100644 --- a/ssh.config +++ b/ssh.config @@ -4,4 +4,4 @@ Host * AddKeysToAgent yes IgnoreUnknown UseKeychain UseKeychain yes - IdentityFile ~/.ssh/id_rsa + IdentityFile ~/.ssh/id_ed25519 diff --git a/vscode-extensions.nix b/vscode-extensions.nix index a08201a..6ec99da 100644 --- a/vscode-extensions.nix +++ b/vscode-extensions.nix @@ -13,19 +13,19 @@ with pkgs.vscode-extensions; { name = "remote-containers"; publisher = "ms-vscode-remote"; - version = "0.222.0"; + version = "0.242.0"; sha256 = "4Li0sYfHOsJMn5FJtvDTGKoGPcRmoosD9tZ7q9H9DfQ="; } { name = "remote-ssh"; publisher = "ms-vscode-remote"; - version = "0.75.2022021903"; + version = "0.85.2022071315"; sha256 = "hTRfoUHKrIOSV8eZ/62ewaII5291huXjOZ++dRUmKoI="; } { name = "vscode-docker"; publisher = "ms-azuretools"; - version = "1.19.0"; + version = "1.22.1"; sha256 = "UPUfTOc5xJhI5ACm2oyWqtZ4zNxZjy16D6Mf30eHFEI="; } { @@ -37,15 +37,9 @@ with pkgs.vscode-extensions; { name = "rust-analyzer"; publisher = "matklad"; - version = "0.3.939"; + version = "0.4.1128"; sha256 = "t5CCUdFCiSYrMsBHG5eOfg3sXMacFWiR0hmVa7S1i8Y="; } - { - name = "vscode-lldb"; - publisher = "vadimcn"; - version = "1.6.10"; - sha256 = "CGVVs//jIZM8uX7Wc9gM4aQGwECi88eIpfPqU2hKbeA="; - } { name = "toml"; publisher = "be5invis"; @@ -61,13 +55,13 @@ with pkgs.vscode-extensions; { name = "lean"; publisher = "jroesch"; - version = "0.16.46"; + version = "0.16.53"; sha256 = "hjflz5JHVr1YWq6QI9DpdNPY1uL7lAuQTMAdwCtLEfY="; } { name = "language-haskell"; publisher = "justusadam"; - version = "3.4.0"; + version = "3.6.0"; sha256 = "0ab7m5jzxakjxaiwmg0jcck53vnn183589bbxh3iiylkpicrv67y"; } { @@ -79,13 +73,13 @@ with pkgs.vscode-extensions; { name = "dotnet-interactive-vscode"; publisher = "ms-dotnettools"; - version = "1.0.3103011"; + version = "1.0.3362041"; sha256 = "a3u9NKsqHZKhZkKqJqo+LgJFTL2yhehBepTOFOXE+jY="; } { name = "python"; publisher = "ms-python"; - version = "2022.0.1814523869"; + version = "2022.11.11961004"; sha256 = "hXTVZ7gbu234zyAg0ZrZPUo6oULB98apxe79U2yQHD4="; } { @@ -103,13 +97,13 @@ with pkgs.vscode-extensions; { name = "trailing-spaces"; publisher = "shardulm94"; - version = "0.3.1"; + version = "0.4.1"; sha256 = "0h30zmg5rq7cv7kjdr5yzqkkc1bs20d72yz9rjqag32gwf46s8b8"; } { name = "debug"; publisher = "webfreak"; - version = "0.25.1"; + version = "0.26.0"; sha256 = "1l01sv6kwh8dlv3kygkkd0z9m37hahflzd5bx1wwij5p61jg7np9"; } ]