mirror of
https://github.com/soywod/himalaya.git
synced 2024-09-29 04:31:11 +00:00
fix nix run (#274)
* replace cargo2nix by naersk * add rust-analyzer and rustfmt to nix build inputs
This commit is contained in:
parent
08d31ef55c
commit
b4ab2329dc
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,5 +5,9 @@
|
||||||
/result
|
/result
|
||||||
/result-lib
|
/result-lib
|
||||||
|
|
||||||
|
# Direnv
|
||||||
|
/.envrc
|
||||||
|
/.direnv
|
||||||
|
|
||||||
# Vim plugin doc tags file
|
# Vim plugin doc tags file
|
||||||
/vim/doc/tags
|
/vim/doc/tags
|
||||||
|
|
90
flake.lock
90
flake.lock
|
@ -1,22 +1,5 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crate2nix": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1608814925,
|
|
||||||
"narHash": "sha256-GdFBG2LmpbY4C1OJBFfWLMKXzGyFq4mJBK+SVMNNE+8=",
|
|
||||||
"owner": "balsoft",
|
|
||||||
"repo": "crate2nix",
|
|
||||||
"rev": "68be3d90f31bf0bfd525da77e0ae6e89f48abd24",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "balsoft",
|
|
||||||
"ref": "tools-nix-version-comparison",
|
|
||||||
"repo": "crate2nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -35,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1614513358,
|
"lastModified": 1637014545,
|
||||||
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -48,42 +31,73 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1639947939,
|
||||||
|
"narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1627857416,
|
"lastModified": 1640418986,
|
||||||
"narHash": "sha256-AV0MsFVzbWI2MZbJ2j0kc8ooFLGSCZHuM9ipaWR9ds4=",
|
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "aaf9676fbb7fb4570216ca1e189a3dc769d62c45",
|
"rev": "5c37ad87222cfc1ec36d6cd1364514a9efc2f7f2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-unstable",
|
"type": "indirect"
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1617325113,
|
"lastModified": 1640418986,
|
||||||
"narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=",
|
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "54c1e44240d8a527a8f4892608c4bce5440c3ecb",
|
"rev": "5c37ad87222cfc1ec36d6cd1364514a9efc2f7f2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1637453606,
|
||||||
|
"narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"crate2nix": "crate2nix",
|
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"nixpkgs": "nixpkgs",
|
"naersk": "naersk",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
"rust-overlay": "rust-overlay",
|
"rust-overlay": "rust-overlay",
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
|
@ -91,14 +105,14 @@
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1627957145,
|
"lastModified": 1642838864,
|
||||||
"narHash": "sha256-cY5lS2S/RMsC1xFtkcmhLXlVP7ahZoxFeKedkXDvIzY=",
|
"narHash": "sha256-pHnhm3HWwtvtOK7NdNHwERih3PgNlacrfeDwachIG8E=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "ab6f3086de97980e4fdcb0560921852a407e0b79",
|
"rev": "9fb49daf1bbe1d91e6c837706c481f9ebb3d8097",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
68
flake.nix
68
flake.nix
|
@ -2,26 +2,20 @@
|
||||||
description = "Command-line interface for email management";
|
description = "Command-line interface for email management";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
crate2nix = {
|
naersk.url = "github:nix-community/naersk";
|
||||||
url = "github:balsoft/crate2nix/tools-nix-version-comparison";
|
|
||||||
flake = false;
|
|
||||||
};
|
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
url = "github:edolstra/flake-compat";
|
url = "github:edolstra/flake-compat";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
|
outputs = { self, nixpkgs, utils, rust-overlay, naersk, ... }:
|
||||||
utils.lib.eachDefaultSystem
|
utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
name = "himalaya";
|
name = "himalaya";
|
||||||
|
|
||||||
# Imports
|
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
overlays = [
|
||||||
|
@ -35,37 +29,23 @@
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
|
naersk-lib = naersk.lib.${system};
|
||||||
generatedCargoNix;
|
in
|
||||||
|
rec {
|
||||||
# Create the cargo2nix project
|
# nix build
|
||||||
project = pkgs.callPackage (generatedCargoNix {
|
defaultPackage = packages.${name};
|
||||||
inherit name;
|
packages = {
|
||||||
src = ./.;
|
${name} = naersk-lib.buildPackage {
|
||||||
}) {
|
pname = name;
|
||||||
# Individual crate overrides go here
|
root = ./.;
|
||||||
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
|
nativeBuildInputs = with pkgs; [ openssl.dev pkgconfig ];
|
||||||
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
overrideMain = _: {
|
||||||
# The himalaya crate itself is overriden here. Typically we
|
|
||||||
# configure non-Rust dependencies (see below) here.
|
|
||||||
${name} = oldAttrs: {
|
|
||||||
inherit buildInputs nativeBuildInputs;
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mkdir -p $out/share/applications/
|
mkdir -p $out/share/applications/
|
||||||
cp assets/himalaya.desktop $out/share/applications/
|
cp assets/himalaya.desktop $out/share/applications/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
# Configuration for the non-Rust dependencies
|
|
||||||
buildInputs = with pkgs; [ openssl.dev ];
|
|
||||||
nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig ];
|
|
||||||
in
|
|
||||||
rec {
|
|
||||||
packages = {
|
|
||||||
${name} = project.rootCrate.build;
|
|
||||||
|
|
||||||
"${name}-vim" = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
"${name}-vim" = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||||
inherit (packages.${name}) version;
|
inherit (packages.${name}) version;
|
||||||
name = "${name}-vim";
|
name = "${name}-vim";
|
||||||
|
@ -80,21 +60,27 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# `nix build`
|
# nix run
|
||||||
defaultPackage = packages.${name};
|
defaultApp = apps.${name};
|
||||||
|
|
||||||
# `nix run`
|
|
||||||
apps.${name} = utils.lib.mkApp {
|
apps.${name} = utils.lib.mkApp {
|
||||||
inherit name;
|
inherit name;
|
||||||
drv = packages.${name};
|
drv = packages.${name};
|
||||||
};
|
};
|
||||||
defaultApp = apps.${name};
|
|
||||||
|
|
||||||
# `nix develop`
|
# nix develop
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
inputsFrom = builtins.attrValues self.packages.${system};
|
|
||||||
buildInputs = with pkgs; [ cargo cargo-watch trunk ];
|
|
||||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||||
|
inputsFrom = builtins.attrValues self.packages.${system};
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
cargo
|
||||||
|
cargo-watch
|
||||||
|
trunk
|
||||||
|
ripgrep
|
||||||
|
rust-analyzer
|
||||||
|
rustfmt
|
||||||
|
rnix-lsp
|
||||||
|
nixpkgs-fmt
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue