aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-06 00:22:02 +0000
committerFuwn <[email protected]>2021-05-06 00:22:02 +0000
commitcfb54fcd29fb25f12c483897873fb98f85269d3b (patch)
tree564b20278d8125bde58cec07cfe79b4537f37d2b
parentchore(global): create version file (diff)
downloadwhirl-cfb54fcd29fb25f12c483897873fb98f85269d3b.tar.xz
whirl-cfb54fcd29fb25f12c483897873fb98f85269d3b.zip
feat(nix): spice it all up
-rw-r--r--default.nix53
-rw-r--r--docker.nix23
-rw-r--r--nix/dhall-yaml.nix5
-rw-r--r--nix/sources.json12
-rw-r--r--shell.nix24
-rw-r--r--whirl.nix17
6 files changed, 99 insertions, 35 deletions
diff --git a/default.nix b/default.nix
index 1b279f4..ff86419 100644
--- a/default.nix
+++ b/default.nix
@@ -1,20 +1,47 @@
-{ system ? builtins.currentSystem }:
+{ sources ? import ./nix/sources.nix, pkgs ? import sources.nixpkgs { } }:
+with pkgs;
let
- sources = import ./nix/sources.nix;
- pkgs = import sources.nixpkgs { };
- whirl = import ./whirl.nix { inherit sources pkgs; };
+ rust = pkgs.callPackage ./nix/rust.nix { };
- name = "Whirlsplash/whirl";
- tag = "latest";
+ srcNoTarget = dir:
+ builtins.filterSource
+ (path: type: type != "directory" || builtins.baseNameOf path != "target")
+ dir;
-in pkgs.dockerTools.buildLayeredImage {
- inherit name tag;
- contents = [ whirl ];
+ naersk = pkgs.callPackage sources.naersk {
+ rustc = rust;
+ cargo = rust;
+ };
+ dhallpkgs = import sources.easy-dhall-nix { inherit pkgs; };
+ src = srcNoTarget ./.;
+
+ whirl = naersk.buildPackage {
+ inherit src;
+ doCheck = true;
+ buildInputs = [ ];
+ remapPathPrefix = true;
+ };
+
+ config = stdenv.mkDerivation {
+ pname = "whirl-config";
+ version = "HEAD";
+ buildInputs = [ dhallpkgs.dhall-simple ];
- config = {
- Cmd = [ "/bin/whirl" ];
- Env = [ ];
- WorkingDir = "/";
+# phases = "installPhase";
+#
+# installPhase = ''
+# '';
};
+
+in pkgs.stdenv.mkDerivation {
+ inherit (whirl) name;
+ inherit src;
+ phases = "installPhase";
+
+ installPhase = ''
+ mkdir -p $out $out/bin
+
+ cp -rf ${whirl}/bin/whirl $out/bin/whirl
+ '';
}
diff --git a/docker.nix b/docker.nix
new file mode 100644
index 0000000..2bee934
--- /dev/null
+++ b/docker.nix
@@ -0,0 +1,23 @@
+{ system ? builtins.currentSystem }:
+
+let
+ sources = import ./nix/sources.nix;
+ pkgs = import sources.nixpkgs { };
+ callPackage = pkgs.lib.callPackageWith pkgs;
+ whirl = callPackage ./default.nix { };
+
+ dockerImage = pkg:
+ pkgs.dockerTools.buildLayeredImage {
+ name = "Whirlsplash/whirl";
+ tag = "latest";
+
+ contents = [ pkg ];
+
+ config = {
+ Cmd = [ "/bin/whirl" ];
+ WorkingDir = "/";
+ Env = [ ];
+ };
+ };
+
+in dockerImage whirl
diff --git a/nix/dhall-yaml.nix b/nix/dhall-yaml.nix
new file mode 100644
index 0000000..ddb8c3d
--- /dev/null
+++ b/nix/dhall-yaml.nix
@@ -0,0 +1,5 @@
+let
+ sources = import ./sources.nix;
+ pkgs = import sources.nixpkgs { };
+ dhall = import sources.easy-dhall-nix { inherit pkgs; };
+in dhall.dhall-yaml-simple
diff --git a/nix/sources.json b/nix/sources.json
index 33453bf..04180f2 100644
--- a/nix/sources.json
+++ b/nix/sources.json
@@ -1,4 +1,16 @@
{
+ "easy-dhall-nix": {
+ "branch": "master",
+ "description": "Derivations for easily downloading Dhall binaries and putting them to use.",
+ "homepage": "",
+ "owner": "justinwoo",
+ "repo": "easy-dhall-nix",
+ "rev": "1f6eecab5c276a59858a10bbfcbbc5611187da03",
+ "sha256": "07n7y93xfiwr82yx2v8r5mxcafsxgs1hdl1ghq6xah5v827fb6q0",
+ "type": "tarball",
+ "url": "https://github.com/justinwoo/easy-dhall-nix/archive/1f6eecab5c276a59858a10bbfcbbc5611187da03.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
"naersk": {
"branch": "master",
"description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.",
diff --git a/shell.nix b/shell.nix
index b7651ac..9013b15 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,10 +1,24 @@
let
sources = import ./nix/sources.nix;
- rust = import ./nix/rust.nix { inherit sources; };
- pkgs = import sources.nixpkgs { };
-in
-pkgs.mkShell {
- buildInputs = with pkgs; [ niv rust ];
+ pkgs = import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; };
+ dhallpkgs = import sources.easy-dhall-nix { inherit pkgs; };
+ dhall-yaml = dhallpkgs.dhall-yaml-simple;
+ dhall = dhallpkgs.dhall-simple;
+ rust = pkgs.callPackage ./nix/rust.nix { };
+in pkgs.mkShell {
+ buildInputs = with pkgs; [
+ # Rust
+ rust
+
+ # Dhall
+ dhall
+ dhall-yaml
+
+ # Dependecy manager
+ niv
+ ];
DATABASE_URL = "whirl.sqlite3";
+ RUST_SRC_PATH = "${pkgs.latest.rustChannels.nightly.rust-src}/lib/rustlib/src/rust/library";
+ RUST_BACKTRACE = "1";
}
diff --git a/whirl.nix b/whirl.nix
deleted file mode 100644
index a08a9b2..0000000
--- a/whirl.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ sources ? import ./nix/sources.nix, pkgs ? import sources.nixpkgs { } }:
-
-let
- rust = import ./nix/rust.nix { inherit sources; };
-
- naersk = pkgs.callPackage sources.naersk {
- rustc = rust;
- cargo = rust;
- };
-
- src = builtins.filterSource
- (path: type: type != "directory" || builtins.baseNameOf path != "target")
- ./.;
-in naersk.buildPackage {
- inherit src;
- remapPathPrefix = true;
-}