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 = [ 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()"; + }; + }; + }; +} 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 = 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 }) + ''; + }; +} 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 diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 2511ce7..93a1e5e 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -1,69 +1,90 @@ { 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"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # wild = { + # url = "github:davidlattimore/wild"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; }; - 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.stdenv; + # stdenv = pkgs.useWildLinker pkgs.stdenv; + } { + 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) + # inputs.wild.overlays.default + ]; }; - 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 = 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; + }; + }; }