Skip to content

feat: initial add of flake for builds #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/_test_area
/site
/result
126 changes: 126 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
description = "an opinionated documentation site generator";

# inputs needed for rust along with some nice tooling for development environment
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
};

outputs = { self, nixpkgs, utils, rust-overlay, naersk, ... }:
let
name = "doctave";
in
utils.lib.eachDefaultSystem (system:
let
# nix packages with rust overlay defaulats instead
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlay
(self: super: {
rustc = self.rust-bin.stable.latest.default;
cargo = self.rust-bin.stable.latest.default;
})
];
};

# override version cargo and rustc version of naersk with overlay
naersk-lib = naersk.lib.${system}.override {
cargo = pkgs.cargo;
rustc = pkgs.rustc;
};

in
rec {
# main package to base all builds from
packages.${name} = naersk-lib.buildPackage {
pname = name;
# root of rust source holding cargo.lock
root = ./.;
};
defaultPackage = packages.${name};
# build out a container image if want to run as a container
packages.container = pkgs.dockerTools.buildImage {
inherit name;
tag = packages.${name}.version;
created = "now";
contents = packages.${name};
config.Cmd = [ "${packages.${name}}/bin/doctave" ];
};
# useful default app to run from nix directly
apps.${name} = utils.lib.mkApp {
inherit name;
drv = packages.${name};
};
defaultApp = apps.${name};

# dev shell default
devShell = pkgs.mkShell {
shellHook = ''
export RUST_SRC_PATH=${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}
'';

nativeBuildInputs = [ pkgs.cargo ];
};
}
);
}