nix autoformat etc
This commit is contained in:
parent
d58930a9ad
commit
4ff4c07906
4 changed files with 47 additions and 39 deletions
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"matklad.rust-analyzer"
|
"matklad.rust-analyzer",
|
||||||
|
"jnoortheen.nix-ide"
|
||||||
]
|
]
|
||||||
}
|
}
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
|
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
|
||||||
|
"editor.formatOnSave": true
|
||||||
}
|
}
|
25
default.nix
25
default.nix
|
@ -1,12 +1,13 @@
|
||||||
# This file exists for legacy Nix installs (nix-build & nix-env)
|
(import
|
||||||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
|
(
|
||||||
# You generally do *not* have to modify this ever.
|
let
|
||||||
(import (
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
let
|
in
|
||||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
fetchTarball {
|
||||||
in fetchTarball {
|
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||||
sha256 = lock.nodes.flake-compat.locked.narHash; }
|
}
|
||||||
) {
|
)
|
||||||
src = ./.;
|
{
|
||||||
}).defaultNix
|
src = ./.;
|
||||||
|
}).defaultNix
|
||||||
|
|
55
flake.nix
55
flake.nix
|
@ -19,15 +19,16 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
|
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
|
||||||
let
|
let
|
||||||
name = "bouncy";
|
name = "bouncy";
|
||||||
in utils.lib.eachDefaultSystem
|
in
|
||||||
|
utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
# Imports
|
# Imports
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
overlays = [
|
||||||
rust-overlay.overlay
|
rust-overlay.overlay
|
||||||
(self: super: {
|
(self: super: {
|
||||||
# Because rust-overlay bundles multiple rust packages into one
|
# Because rust-overlay bundles multiple rust packages into one
|
||||||
|
@ -42,28 +43,31 @@
|
||||||
generatedCargoNix;
|
generatedCargoNix;
|
||||||
|
|
||||||
# Create the cargo2nix project
|
# Create the cargo2nix project
|
||||||
project = pkgs.callPackage (generatedCargoNix {
|
project = pkgs.callPackage
|
||||||
inherit name;
|
(generatedCargoNix {
|
||||||
src = ./.;
|
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 // {
|
# Individual crate overrides go here
|
||||||
# The himalaya crate itself is overriden here. Typically we
|
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
|
||||||
# configure non-Rust dependencies (see below) here.
|
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
||||||
${name} = oldAttrs: {
|
# The himalaya crate itself is overriden here. Typically we
|
||||||
inherit buildInputs nativeBuildInputs;
|
# configure non-Rust dependencies (see below) here.
|
||||||
} // buildEnvVars;
|
${name} = oldAttrs: {
|
||||||
|
inherit buildInputs nativeBuildInputs;
|
||||||
|
} // buildEnvVars;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
# Configuration for the non-Rust dependencies
|
# Configuration for the non-Rust dependencies
|
||||||
buildInputs = with pkgs; [ openssl.dev ];
|
buildInputs = with pkgs; [ openssl.dev ];
|
||||||
nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig ];
|
nativeBuildInputs = with pkgs; [ rustc cargo pkgconfig nixpkgs-fmt ];
|
||||||
buildEnvVars = {
|
buildEnvVars = {
|
||||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||||
};
|
};
|
||||||
in rec {
|
in
|
||||||
|
rec {
|
||||||
packages.${name} = project.rootCrate.build;
|
packages.${name} = project.rootCrate.build;
|
||||||
|
|
||||||
# `nix build`
|
# `nix build`
|
||||||
|
@ -77,10 +81,11 @@
|
||||||
defaultApp = apps.${name};
|
defaultApp = apps.${name};
|
||||||
|
|
||||||
# `nix develop`
|
# `nix develop`
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell
|
||||||
inherit buildInputs nativeBuildInputs;
|
{
|
||||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
inherit buildInputs nativeBuildInputs;
|
||||||
} // buildEnvVars;
|
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||||
|
} // buildEnvVars;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue