-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from arulagrawal/nix-flake
add nix flake
- Loading branch information
Showing
4 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
.env | ||
# Idea Files | ||
.idea/ | ||
|
||
# nix files | ||
.direnv/ | ||
result |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
description = "Redlib: Private front-end for Reddit"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
|
||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs = { | ||
nixpkgs.follows = "nixpkgs"; | ||
flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
}; | ||
|
||
outputs = { nixpkgs, crane, flake-utils, rust-overlay, ... }: | ||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ (import rust-overlay) ]; | ||
}; | ||
|
||
inherit (pkgs) lib; | ||
|
||
rustToolchain = pkgs.rust-bin.stable.latest.default.override { | ||
targets = [ "x86_64-unknown-linux-musl" ]; | ||
}; | ||
|
||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; | ||
|
||
|
||
src = lib.cleanSourceWith { | ||
src = craneLib.path ./.; | ||
filter = path: type: | ||
(lib.hasInfix "/templates/" path) || | ||
(lib.hasInfix "/static/" path) || | ||
(craneLib.filterCargoSources path type); | ||
}; | ||
|
||
redlib = craneLib.buildPackage { | ||
inherit src; | ||
strictDeps = true; | ||
doCheck = false; | ||
|
||
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; | ||
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static"; | ||
}; | ||
in | ||
{ | ||
checks = { | ||
my-crate = redlib; | ||
}; | ||
|
||
packages.default = redlib; | ||
packages.docker = pkgs.dockerTools.buildImage { | ||
name = "quay.io/redlib/redlib"; | ||
tag = "latest"; | ||
created = "now"; | ||
copyToRoot = with pkgs.dockerTools; [ caCertificates fakeNss ]; | ||
config.Cmd = "${redlib}/bin/redlib"; | ||
}; | ||
}); | ||
} |