Skip to content

Commit

Permalink
feat(mise): add mise package and configuration support
Browse files Browse the repository at this point in the history
  • Loading branch information
rodent1 committed Jan 7, 2025
1 parent 59d2077 commit dda14c8
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 5 deletions.
1 change: 1 addition & 0 deletions homes/_modules/shell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
./fzf
./gh
./git
./mise
./nvim
./starship
./tmux
Expand Down
4 changes: 2 additions & 2 deletions homes/_modules/shell/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ in
"Thumbs.db"
# asdf
".tool-versions"
# mise
".mise.toml"
# Sops
".decrypted~*"
"*.decrypted.*"
# Python virtualenvs
".venv"
# Direnv files
".direnv"
];
signing = {
signByDefault = true;
Expand Down
69 changes: 69 additions & 0 deletions homes/_modules/shell/mise/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.modules.shell.mise;
tomlFormat = pkgs.formats.toml { };
in
{
options.modules.shell.mise = {
enable = lib.mkEnableOption "mise";
package = lib.mkPackageOption pkgs "mise" { };
globalConfig = lib.mkOption {
inherit (tomlFormat) type;
default = { };
};
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
};
};

config = lib.mkIf cfg.enable {
home.packages = [
cfg.package
pkgs.usage
];

home.activation.miseInstall = ''
${lib.getExe cfg.package} install -C "${config.home.homeDirectory}"
${lib.getExe cfg.package} use -g usage
${lib.getExe cfg.package} completion fish > ~/.config/fish/completions/mise.fish
'';

xdg.configFile = {
"mise/config.toml" = lib.mkIf (cfg.globalConfig != { }) {
source = tomlFormat.generate "mise-config" cfg.globalConfig;
};
"mise/settings.toml" = {
source = tomlFormat.generate "mise-settings" (
{
experimental = true;
python_venv_auto_create = true;
disable_hints = [
"*"
];
}
// cfg.settings
);
};
};

programs = {
bash.initExtra = ''
eval "$(${lib.getExe cfg.package} activate bash)"
'';

fish.interactiveShellInit = lib.mkAfter ''
${lib.getExe cfg.package} activate fish | source
'';

fish.shellInit = lib.mkAfter ''
${lib.getExe cfg.package} activate fish --shims | source
'';
};
};
}
7 changes: 6 additions & 1 deletion homes/stianrs/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ hostname, ... }:
{ hostname, pkgs, ... }:
{
imports = [
../_modules
Expand Down Expand Up @@ -52,6 +52,11 @@
signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBACoz3DyvP3a6ujHA2MLlzKKlW9VAJ2V8+fa9mMzC0x";
};

mise = {
enable = true;
package = pkgs.unstable.mise;
};

fzf.enable = true;
nvim.enable = true;
tmux.enable = true;
Expand Down
20 changes: 20 additions & 0 deletions pkgs/_sources/generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,25 @@
"type": "github"
},
"version": "v1.9.1"
},
"usage": {
"cargoLocks": null,
"date": null,
"extract": null,
"name": "usage",
"passthru": null,
"pinned": false,
"src": {
"deepClone": false,
"fetchSubmodules": false,
"leaveDotGit": false,
"name": null,
"owner": "jdx",
"repo": "usage",
"rev": "v1.7.4",
"sha256": "sha256-+Wt/ZOwj9LHgt0EOFF554TGf2tZyuRoXAPpCebPZfNY=",
"type": "github"
},
"version": "v1.7.4"
}
}
11 changes: 11 additions & 0 deletions pkgs/_sources/generated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@
sha256 = "sha256-Qvt9/okT37J3ge/lb17OX4aaiXbSFU1j7drdiJDqFnA=";
};
};
usage = {
pname = "usage";
version = "v1.7.4";
src = fetchFromGitHub {
owner = "jdx";
repo = "usage";
rev = "v1.7.4";
fetchSubmodules = false;
sha256 = "sha256-+Wt/ZOwj9LHgt0EOFF554TGf2tZyuRoXAPpCebPZfNY=";
};
};
}
5 changes: 3 additions & 2 deletions pkgs/_sources/vendorhash.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"talosctl": "sha256-vZFXqU9tgnL8odBpOcvRig1KKVH20CM0ze0+pypaRKE=",
"gh-copilot-linux-amd64": "",
"gh-copilot-linux-arm64": "",
"gh-copilot-darwin-amd64": "",
"gh-copilot-darwin-arm64": ""
"gh-copilot-darwin-arm64": "",
"talosctl": "sha256-vZFXqU9tgnL8odBpOcvRig1KKVH20CM0ze0+pypaRKE=",
"usage": "sha256-w8GWvMjC6Plho+zw542Q00hU/KZMdyyoP/rGAg72h1s="
}
1 change: 1 addition & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
kubecolor-catppuccin = pkgs.callPackage ./kubecolor-catppuccin.nix { };
talhelper = inputs.talhelper.packages.${system}.default;
talosctl = pkgs.callPackage ./talosctl.nix { };
usage = pkgs.callPackage ./usage.nix { };
}
3 changes: 3 additions & 0 deletions pkgs/nvfetcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ fetch.github = "vkhitrin/kubecolor-catppuccin"
[talosctl]
src.github = "siderolabs/talos"
fetch.github = "siderolabs/talos"
[usage]
src.github = "jdx/usage"
fetch.github = "jdx/usage"
33 changes: 33 additions & 0 deletions pkgs/usage.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
pkgs,
lib,
rustPlatform,
nix-update-script,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
inherit (pkgs.darwin.apple_sdk.frameworks) Security SystemConfiguration;

sourceData = pkgs.callPackage ./_sources/generated.nix { };
vendorHash = lib.importJSON ./_sources/vendorhash.json;
packageData = sourceData.usage;
in
rustPlatform.buildRustPackage rec {
inherit (packageData) pname src;
version = lib.strings.removePrefix "v" packageData.version;
cargoHash = vendorHash.usage;

passthru = {
updateScript = nix-update-script { };
};

doCheck = false; # no tests

meta = {
homepage = "https://usage.jdx.dev";
description = "A specification for CLIs";
changelog = "https://github.com/jdx/usage/releases/tag/v${version}";
mainProgram = "usage";
};
}

0 comments on commit dda14c8

Please sign in to comment.