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-lib
|
||||
|
||||
# Direnv
|
||||
/.envrc
|
||||
/.direnv
|
||||
|
||||
# Vim plugin doc tags file
|
||||
/vim/doc/tags
|
||||
|
|
90
flake.lock
90
flake.lock
|
@ -1,22 +1,5 @@
|
|||
{
|
||||
"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": false,
|
||||
"locked": {
|
||||
|
@ -35,11 +18,11 @@
|
|||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1614513358,
|
||||
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
||||
"lastModified": 1637014545,
|
||||
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
||||
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -48,42 +31,73 @@
|
|||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1627857416,
|
||||
"narHash": "sha256-AV0MsFVzbWI2MZbJ2j0kc8ooFLGSCZHuM9ipaWR9ds4=",
|
||||
"owner": "nixos",
|
||||
"lastModified": 1640418986,
|
||||
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "aaf9676fbb7fb4570216ca1e189a3dc769d62c45",
|
||||
"rev": "5c37ad87222cfc1ec36d6cd1364514a9efc2f7f2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1617325113,
|
||||
"narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=",
|
||||
"owner": "nixos",
|
||||
"lastModified": 1640418986,
|
||||
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
|
||||
"owner": "NixOS",
|
||||
"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"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
|
@ -91,14 +105,14 @@
|
|||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1627957145,
|
||||
"narHash": "sha256-cY5lS2S/RMsC1xFtkcmhLXlVP7ahZoxFeKedkXDvIzY=",
|
||||
"lastModified": 1642838864,
|
||||
"narHash": "sha256-pHnhm3HWwtvtOK7NdNHwERih3PgNlacrfeDwachIG8E=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "ab6f3086de97980e4fdcb0560921852a407e0b79",
|
||||
"rev": "9fb49daf1bbe1d91e6c837706c481f9ebb3d8097",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
68
flake.nix
68
flake.nix
|
@ -2,26 +2,20 @@
|
|||
description = "Command-line interface for email management";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
crate2nix = {
|
||||
url = "github:balsoft/crate2nix/tools-nix-version-comparison";
|
||||
flake = false;
|
||||
};
|
||||
naersk.url = "github:nix-community/naersk";
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
|
||||
outputs = { self, nixpkgs, utils, rust-overlay, naersk, ... }:
|
||||
utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
name = "himalaya";
|
||||
|
||||
# Imports
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
|
@ -35,37 +29,23 @@
|
|||
})
|
||||
];
|
||||
};
|
||||
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
|
||||
generatedCargoNix;
|
||||
|
||||
# Create the cargo2nix project
|
||||
project = pkgs.callPackage (generatedCargoNix {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
}) {
|
||||
# Individual crate overrides go here
|
||||
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
|
||||
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
||||
# The himalaya crate itself is overriden here. Typically we
|
||||
# configure non-Rust dependencies (see below) here.
|
||||
${name} = oldAttrs: {
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
naersk-lib = naersk.lib.${system};
|
||||
in
|
||||
rec {
|
||||
# nix build
|
||||
defaultPackage = packages.${name};
|
||||
packages = {
|
||||
${name} = naersk-lib.buildPackage {
|
||||
pname = name;
|
||||
root = ./.;
|
||||
nativeBuildInputs = with pkgs; [ openssl.dev pkgconfig ];
|
||||
overrideMain = _: {
|
||||
postInstall = ''
|
||||
mkdir -p $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 {
|
||||
inherit (packages.${name}) version;
|
||||
name = "${name}-vim";
|
||||
|
@ -80,21 +60,27 @@
|
|||
};
|
||||
};
|
||||
|
||||
# `nix build`
|
||||
defaultPackage = packages.${name};
|
||||
|
||||
# `nix run`
|
||||
# nix run
|
||||
defaultApp = apps.${name};
|
||||
apps.${name} = utils.lib.mkApp {
|
||||
inherit name;
|
||||
drv = packages.${name};
|
||||
};
|
||||
defaultApp = apps.${name};
|
||||
|
||||
# `nix develop`
|
||||
# nix develop
|
||||
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}";
|
||||
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