mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-21 10:30:20 +00:00
add nix support (#76)
* Add default.nix for nix support * Convert to flake * gitignore before building the source * Add default.nix and shell.nix for legacy workflows * Use https://github.com/oxalica/rust-overlay This one works for development workflow, with a functional rust-analyzer for using with language server support in IDEs. Also add .vscode/ for pre-configured settings. * Add documentation * Restore old TOC and apply TOC patch manually * Clarify that these two commands are either-or * Add installing from local checkout (nix-env) * Add note about version update * Improve Nix workflow, for zero maintenance Use https://github.com/nmattia/naersk This avoids having to set a sha and version in Nix scripts. * Simplify using crate2nix Ref: https://www.reddit.com/r/rust/comments/mmbfnj/nixifying_a_rust_project/ * Use rootCrate * Propagate openssl deps to non-shell build * Try the oxalica overlay * Get rid of gitignore crate cf. https://www.reddit.com/r/rust/comments/mmbfnj/nixifying_a_rust_project/gtsgxal/?context=3 * Configure himalaya crate under defaultCrateOverrides * Specify openssl in buildInputs * Make a note about a potential error when using Nix 2.4pre * Remove PKG_CONFIG_PATH (unnecessary) * Add cargo-watch Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru> Co-authored-by: Alexander Bantyev <balsoft@balsoft.ru>
This commit is contained in:
parent
95b99c25da
commit
76f9084f91
8 changed files with 284 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/target
|
||||
/vim/doc/tags
|
||||
/result
|
||||
/result-lib
|
||||
|
|
6
.vscode/extensions.json
vendored
Normal file
6
.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"matklad.rust-analyzer",
|
||||
"arrterian.nix-env-selector"
|
||||
]
|
||||
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
|
||||
}
|
41
README.md
41
README.md
|
@ -11,6 +11,9 @@ Minimalist CLI email client, written in Rust.
|
|||
|
||||
* [Motivation](#motivation)
|
||||
* [Installation](#installation)
|
||||
* [Nix](#nix)
|
||||
* [Installing using Nix](#installing-using-nix)
|
||||
* [Development using Nix](#development-using-nix)
|
||||
* [Configuration](#configuration)
|
||||
* [Usage](#usage)
|
||||
* [List mailboxes](#list-mailboxes)
|
||||
|
@ -51,9 +54,45 @@ more flexibility.
|
|||
curl -sSL https://raw.githubusercontent.com/soywod/himalaya/master/install.sh | sh
|
||||
```
|
||||
|
||||
*See the [wiki section](https://github.com/soywod/himalaya/wiki/Installation)
|
||||
Read the Nix section below for a Nix-based installation method. *See the [wiki section](https://github.com/soywod/himalaya/wiki/Installation)
|
||||
for other installation methods.*
|
||||
|
||||
## Nix
|
||||
|
||||
[Nix](https://serokell.io/blog/what-is-nix) users might find this section relevant.
|
||||
|
||||
### Installing using Nix
|
||||
|
||||
If you already have Nix installed (without Flakes), run the following command to install himalaya to your home directory:
|
||||
|
||||
```bash
|
||||
nix-env -if https://github.com/soywod/himalaya/archive/master.tar.gz
|
||||
# Or, `nix-env -if .` from within the source tree checkout
|
||||
```
|
||||
|
||||
Alternatively, if you use Nix with [Flakes](https://nixos.wiki/wiki/Flakes), you can directly run himalaya without installing it anywhere:
|
||||
|
||||
```bash
|
||||
nix run github:soywod/himalaya
|
||||
# Or, `nix run` from within the source tree checkout
|
||||
```
|
||||
|
||||
### Development using Nix
|
||||
|
||||
To enter a development shell,
|
||||
|
||||
```bash
|
||||
nix develop
|
||||
```
|
||||
|
||||
From here, you have access to all the development tools (Rust compiler, cargo, rust language server, code formatter, etc.) necessary to hack on himalaya.
|
||||
|
||||
If you use VSCode, simply open this project folder - and accept the workspace extension recommendations.
|
||||
|
||||
#### Troubleshooting Nix
|
||||
|
||||
- See [here](https://github.com/soywod/himalaya/pull/76#discussion_r609710097) if you get the `hash mismatch in fixed-output derivation` error.
|
||||
|
||||
## Configuration
|
||||
|
||||
```toml
|
||||
|
|
12
default.nix
Normal file
12
default.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
# This file exists for legacy Nix installs (nix-build & nix-env)
|
||||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
|
||||
# You generally do *not* have to modify this ever.
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).defaultNix
|
128
flake.lock
Normal file
128
flake.lock
Normal file
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
"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": {
|
||||
"lastModified": 1606424373,
|
||||
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1614513358,
|
||||
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1617636226,
|
||||
"narHash": "sha256-iZhBWrOR2DoDs1C+0FlnM9AQLMol/qoGQ+d+S43CKJM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3d1a7716d7f1fccbd7d30ab3b2ed3db831f43bde",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1617325113,
|
||||
"narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "54c1e44240d8a527a8f4892608c4bce5440c3ecb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1617848844,
|
||||
"narHash": "sha256-nhPuATSHRrzfZNjtl8zmMhZklYFCHiQd7+uf+jQbd+o=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "70330a767d25daa6063e89e38d68b94b2d971831",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1617631617,
|
||||
"narHash": "sha256-PARRCz55qN3gy07VJZIlFeOX420d0nGF0RzGI/9hVlw=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b2c27d1a81b0dc266270fa8aeecebbd1807fc610",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
81
flake.nix
Normal file
81
flake.nix
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
description = "Minimalist CLI email client";
|
||||
|
||||
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;
|
||||
};
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
|
||||
utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
name = "himalaya";
|
||||
|
||||
# Imports
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlay
|
||||
(self: super: {
|
||||
# Because rust-overlay bundles multiple rust packages into one
|
||||
# derivation, specify that mega-bundle here, so that crate2nix
|
||||
# will use them automatically.
|
||||
rustc = self.rust-bin.stable.latest.default;
|
||||
cargo = self.rust-bin.stable.latest.default;
|
||||
})
|
||||
];
|
||||
};
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Configuration for the non-Rust dependencies
|
||||
buildInputs = with pkgs; [ openssl.dev ];
|
||||
nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig ];
|
||||
in rec {
|
||||
packages.${name} = project.rootCrate.build;
|
||||
|
||||
# `nix build`
|
||||
defaultPackage = packages.${name};
|
||||
|
||||
# `nix run`
|
||||
apps.${name} = utils.lib.mkApp {
|
||||
inherit name;
|
||||
drv = packages.${name};
|
||||
};
|
||||
defaultApp = apps.${name};
|
||||
|
||||
# `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}";
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
12
shell.nix
Normal file
12
shell.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
# This file exists for legacy nix-shell
|
||||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
|
||||
# You generally do *not* have to modify this ever.
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).shellNix
|
Loading…
Reference in a new issue