From 8de1521ec97e8d9b6d7c58de7bd65b3cdedeb0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 12 Jun 2025 09:47:22 +0200 Subject: [PATCH 1/7] feat: add jj profile --- machines/moritz-desktop/configuration.nix | 32 +---------------- machines/moritz-laptop/configuration.nix | 1 + modules/moritz/profiles/jujutsu.nix | 42 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 modules/moritz/profiles/jujutsu.nix diff --git a/machines/moritz-desktop/configuration.nix b/machines/moritz-desktop/configuration.nix index e089aed..4bb254d 100644 --- a/machines/moritz-desktop/configuration.nix +++ b/machines/moritz-desktop/configuration.nix @@ -34,6 +34,7 @@ personal.contacts = true; impermanence.enable = true; webis.enable = true; + jujutsu.enable = true; }; programs.prismlauncher.enable = true; programs.aider.enable = true; @@ -47,37 +48,6 @@ networking.firewall.allowedTCPPorts = [9090]; - # TODO: make this its own module! - home-manager.users.moritz.programs.jujutsu = { - enable = true; - settings = { - user = { - email = "mail@moritzboeh.me"; - name = "Moritz Böhme"; - }; - ui.paginate = "never"; - ui.default-command = "log"; - signing = { - behavior = "drop"; - backend = "gpg"; - key = "0x970C6E89EB0547A9"; - }; - git.sign-on-push = true; - aliases = { - tug = ["bookmark" "move" "--from" "closest_bookmark(@)" "--to" "closest_pushable(@)"]; - mm-update = ["rebase" "--source" "closest_merge(@)" "--destination" "all:closest_merge(@)-"]; - mm-rebase = ["rebase" "--source" "all:roots(trunk()..closest_merge(@))"]; - }; - revset-aliases = { - "closest_bookmark(to)" = "heads(::to & bookmarks())"; - "closest_pushable(to)" = "heads(::to & mutable() & ~description(exact:'') & (~empty() | merges()) & ~private())"; - "closest_merge(to)" = "heads(::to & merges())"; - "private()" = "description(glob:'wip:*') | description(glob:'private:*')"; - }; - git.private-commits = "private()"; - }; - }; - home-manager.users.moritz.services.kanshi.settings = [ { profile.name = "default"; diff --git a/machines/moritz-laptop/configuration.nix b/machines/moritz-laptop/configuration.nix index 0107bda..b5d6bfc 100644 --- a/machines/moritz-laptop/configuration.nix +++ b/machines/moritz-laptop/configuration.nix @@ -35,6 +35,7 @@ personal.contacts = true; personal.calendar = true; impermanence.enable = true; + jujutsu.enable = true; }; programs.aider.enable = true; }; diff --git a/modules/moritz/profiles/jujutsu.nix b/modules/moritz/profiles/jujutsu.nix new file mode 100644 index 0000000..c376bf3 --- /dev/null +++ b/modules/moritz/profiles/jujutsu.nix @@ -0,0 +1,42 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.profiles.jujutsu; +in { + options.my.profiles.jujutsu.enable = mkEnableOption "jujutsu profile"; + + config = mkIf cfg.enable { + home-manager.users.moritz.programs.jujutsu = { + enable = true; + settings = { + user = { + email = "mail@moritzboeh.me"; + name = "Moritz Böhme"; + }; + ui.paginate = "never"; + ui.default-command = "log"; + signing = { + behavior = "drop"; + backend = "gpg"; + key = "0x970C6E89EB0547A9"; + }; + git.sign-on-push = true; + aliases = { + tug = ["bookmark" "move" "--from" "closest_bookmark(@)" "--to" "closest_pushable(@)"]; + mm-update = ["rebase" "--source" "closest_merge(@)" "--destination" "all:closest_merge(@)-"]; + mm-rebase = ["rebase" "--source" "all:roots(trunk()..closest_merge(@))"]; + }; + revset-aliases = { + "closest_bookmark(to)" = "heads(::to & bookmarks())"; + "closest_pushable(to)" = "heads(::to & mutable() & ~description(exact:'') & (~empty() | merges()) & ~private())"; + "closest_merge(to)" = "heads(::to & merges())"; + "private()" = "description(glob:'wip:*') | description(glob:'private:*')"; + }; + git.private-commits = "private()"; + }; + }; + }; +} From 930d4ab4ff5df48f49e1308190867a84bf32a1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 12 Jun 2025 10:04:49 +0200 Subject: [PATCH 2/7] style: remove comments --- templates/rust/.gitignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/templates/rust/.gitignore b/templates/rust/.gitignore index d38c33a..36733f6 100644 --- a/templates/rust/.gitignore +++ b/templates/rust/.gitignore @@ -1,9 +1,5 @@ -# Created by https://www.toptal.com/developers/gitignore/api/rust,direnv -# Edit at https://www.toptal.com/developers/gitignore?templates=rust,direnv - ### direnv ### .direnv -.envrc ### Rust ### # Generated by Cargo @@ -20,5 +16,3 @@ target/ # MSVC Windows builds of rustc generate these, which store debugging information *.pdb - -# End of https://www.toptal.com/developers/gitignore/api/rust,direnv From 63e029286d771056d9e5cc517d85f0ac61734ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 12 Jun 2025 10:05:27 +0200 Subject: [PATCH 3/7] feat: remove remote builders --- flake.nix | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index 05b4b98..cfa9694 100644 --- a/flake.nix +++ b/flake.nix @@ -82,14 +82,8 @@ inventory = { machines = { - moritz-desktop.tags = ["peer" "client" "worker"]; - moritz-laptop.tags = ["peer" "client" "worker"]; - moritz-server.tags = ["client" "worker"]; - }; - instances."remote-builders" = { - module.name = "remote-builders"; - roles.client.tags.client = {}; - roles.worker.tags.worker = {}; + moritz-desktop.tags = ["peer"]; + moritz-laptop.tags = ["peer"]; }; services.zerotier.default = { roles.peer.tags = [ From 6a45c8c099c15958031aad85966004f9c38652a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 12 Jun 2025 11:12:01 +0200 Subject: [PATCH 4/7] refactor!: rust flake template --- templates/rust/Cargo.toml | 10 ++++ templates/rust/flake.nix | 120 ++++++++++++++++++------------------- templates/rust/src/main.rs | 3 + 3 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 templates/rust/Cargo.toml create mode 100644 templates/rust/src/main.rs diff --git a/templates/rust/Cargo.toml b/templates/rust/Cargo.toml new file mode 100644 index 0000000..63b8562 --- /dev/null +++ b/templates/rust/Cargo.toml @@ -0,0 +1,10 @@ +# This line needs to come before anything else in Cargo.toml +cargo-features = ["codegen-backend"] + +[package] +name = "example" +version = "0.1.0" +edition = "2024" + +[profile.dev] +codegen-backend = "cranelift" diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 2511ce7..dfa8a72 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -1,69 +1,69 @@ { inputs = { - crane.url = "github:ipetkov/crane"; - crane.inputs.nixpkgs.follows = "nixpkgs"; - fenix.url = "github:nix-community/fenix"; - fenix.inputs.nixpkgs.follows = "nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { - crane, - flake-utils, - nixpkgs, - ... - } @ inputs: - flake-utils.lib.eachDefaultSystem ( - system: let - inherit (pkgs) lib; - pkgs = import nixpkgs {inherit system;}; - fenix = inputs.fenix.packages.${system}; - craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain; - mkSrc = extraPaths: - with lib.fileset; let - root = ./.; - rustFiles = fromSource (craneLib.cleanCargoSource root); - fileset = union rustFiles (unions extraPaths); - in - toSource {inherit root fileset;}; + outputs = inputs: + inputs.flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux"]; + perSystem = { + self', + pkgs, + system, + ... + }: let + runtimeDeps = with pkgs; []; + buildDeps = with pkgs; [pkg-config rustPlatform.bindgenHook]; + devDeps = with pkgs; []; - ## Customize here ## - toolchain = fenix.complete; # or fenix.stable; - stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv; + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + msrv = cargoToml.package.rust-version; + + rustPackage = features: + (pkgs.makeRustPlatform { + cargo = pkgs.rust-bin.stable.latest.minimal; + rustc = pkgs.rust-bin.stable.latest.minimal; + }).buildRustPackage { + inherit (cargoToml.package) name version; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + buildFeatures = features; + buildInputs = runtimeDeps; + nativeBuildInputs = buildDeps; + # Uncomment if your cargo tests require networking or otherwise + # don't play nicely with the Nix build sandbox: + # doCheck = false; + }; + + mkDevShell = rustc: + pkgs.mkShell.override { + stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; + } { + shellHook = '' + export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} + ''; + buildInputs = runtimeDeps; + nativeBuildInputs = buildDeps ++ devDeps ++ [rustc]; + }; in { - packages.default = craneLib.buildPackage { - inherit stdenv; - src = mkSrc []; - strictDeps = true; - buildInputs = - [ - # Add additional build inputs here - ] - ++ lib.optionals pkgs.stdenv.isDarwin [ - # Additional darwin specific inputs can be set here - pkgs.libiconv - ]; - # Additional environment variables can be set directly - # MY_CUSTOM_VAR = "some value"; + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [(import inputs.rust-overlay)]; }; - devShells.default = - pkgs.mkShell.override {inherit stdenv;} - { - nativeBuildInputs = with pkgs; - [ - # Add additional build inputs here - ] - ++ (with toolchain; [ - cargo - clippy - rustfmt - rustc - fenix.rust-analyzer - ]); - RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library"; - }; - } - ); + packages.default = self'.packages.example; + devShells.default = self'.devShells.nightly; + + packages.example = rustPackage ""; + + devShells.nightly = mkDevShell ((pkgs.rust-bin.selectLatestNightlyWith + (toolchain: toolchain.default)).override { + extensions = ["rustc-codegen-cranelift-preview"]; + }); + devShells.stable = mkDevShell pkgs.rust-bin.stable.latest.default; + devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default; + }; + }; } diff --git a/templates/rust/src/main.rs b/templates/rust/src/main.rs new file mode 100644 index 0000000..5dd30d1 --- /dev/null +++ b/templates/rust/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello World!") +} From e9832d91b2c8fd26a3e42e701a2d989df24e3c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 12 Jun 2025 17:02:56 +0200 Subject: [PATCH 5/7] refactor!: improve rust flake further --- templates/rust/Cargo.toml | 10 ---------- templates/rust/flake.nix | 35 ++++++++++++++++++++++++++++------- templates/rust/src/main.rs | 3 --- 3 files changed, 28 insertions(+), 20 deletions(-) delete mode 100644 templates/rust/Cargo.toml delete mode 100644 templates/rust/src/main.rs diff --git a/templates/rust/Cargo.toml b/templates/rust/Cargo.toml deleted file mode 100644 index 63b8562..0000000 --- a/templates/rust/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -# This line needs to come before anything else in Cargo.toml -cargo-features = ["codegen-backend"] - -[package] -name = "example" -version = "0.1.0" -edition = "2024" - -[profile.dev] -codegen-backend = "cranelift" diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index dfa8a72..93a1e5e 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -2,7 +2,14 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; - rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # wild = { + # url = "github:davidlattimore/wild"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; }; outputs = inputs: @@ -39,7 +46,8 @@ mkDevShell = rustc: pkgs.mkShell.override { - stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; + stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv; + # stdenv = pkgs.useWildLinker pkgs.stdenv; } { shellHook = '' export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} @@ -50,7 +58,10 @@ in { _module.args.pkgs = import inputs.nixpkgs { inherit system; - overlays = [(import inputs.rust-overlay)]; + overlays = [ + (import inputs.rust-overlay) + # inputs.wild.overlays.default + ]; }; packages.default = self'.packages.example; @@ -58,10 +69,20 @@ packages.example = rustPackage ""; - devShells.nightly = mkDevShell ((pkgs.rust-bin.selectLatestNightlyWith - (toolchain: toolchain.default)).override { - extensions = ["rustc-codegen-cranelift-preview"]; - }); + devShells.nightly = let + nightly = (pkgs.rust-bin.selectLatestNightlyWith + (toolchain: toolchain.default)).override { + extensions = ["rustc-codegen-cranelift-preview"]; + }; + devShell = mkDevShell nightly; + in + devShell.overrideAttrs (old: { + shellHook = + old.shellHook or "" + + '' + export RUSTFLAGS="-Zcodegen-backend=cranelift" + ''; + }); devShells.stable = mkDevShell pkgs.rust-bin.stable.latest.default; devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default; }; diff --git a/templates/rust/src/main.rs b/templates/rust/src/main.rs deleted file mode 100644 index 5dd30d1..0000000 --- a/templates/rust/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello World!") -} From 982f6809402c08ab5ad69d61507cfb84c314ad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 20 Jun 2025 16:27:51 +0200 Subject: [PATCH 6/7] feat: add tiny-inline-diagnostics --- .../nvim/plugins/tiny-inline-diagnostics.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 modules/moritz/programs/nvim/plugins/tiny-inline-diagnostics.nix diff --git a/modules/moritz/programs/nvim/plugins/tiny-inline-diagnostics.nix b/modules/moritz/programs/nvim/plugins/tiny-inline-diagnostics.nix new file mode 100644 index 0000000..1e67b23 --- /dev/null +++ b/modules/moritz/programs/nvim/plugins/tiny-inline-diagnostics.nix @@ -0,0 +1,17 @@ +{pkgs, ...}: { + home-manager.users.moritz.programs.nixvim = { + extraPlugins = [pkgs.vimPlugins.tiny-inline-diagnostic-nvim]; + extraConfigLuaPost = '' + require('tiny-inline-diagnostic').setup({ + preset = "powerline", + options = { + throttle = 0, + multilines = { + enabled = true, + }, + }, + }) + vim.diagnostic.config({ virtual_text = false }) + ''; + }; +} From 892f03c6e53bd39105253305a720039bac32cde5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 20 Jun 2025 16:28:56 +0200 Subject: [PATCH 7/7] refactor: fish plugins --- modules/moritz/programs/fish.nix | 36 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/moritz/programs/fish.nix b/modules/moritz/programs/fish.nix index 7990f77..0daef0c 100644 --- a/modules/moritz/programs/fish.nix +++ b/modules/moritz/programs/fish.nix @@ -18,7 +18,6 @@ in { config = lib.mkIf cfg.enable { # set as default shell users.users.moritz.shell = pkgs.fish; - environment.systemPackages = with pkgs.fishPlugins; [fzf-fish pisces]; # needed for nix completions programs.fish.enable = true; @@ -26,17 +25,30 @@ in { programs = { fish = { enable = true; - plugins = [ - { - name = "fish-completion-sync"; - src = pkgs.fetchFromGitHub { - owner = "pfgray"; - repo = "fish-completion-sync"; - rev = "ba70b6457228af520751eab48430b1b995e3e0e2"; - sha256 = "sha256-JdOLsZZ1VFRv7zA2i/QEZ1eovOym/Wccn0SJyhiP9hI="; - }; - } - ]; + plugins = let + mkDef = pkg: { + name = pkg.pname; + src = pkg.src; + }; + plugins = with pkgs.fishPlugins; [ + sponge + pisces + colored-man-pages + done + ]; + in + map mkDef plugins + ++ [ + { + name = "fish-completion-sync"; + src = pkgs.fetchFromGitHub { + owner = "iynaix"; + repo = "fish-completion-sync"; + rev = "4f058ad2986727a5f510e757bc82cbbfca4596f0"; + sha256 = "sha256-kHpdCQdYcpvi9EFM/uZXv93mZqlk1zCi2DRhWaDyK5g="; + }; + } + ]; shellAbbrs = shellConfig.abbreviations; shellAliases = shellConfig.aliases; shellInit =