setup flake

This commit is contained in:
Adithya 2023-07-11 23:07:49 +05:30
parent 038f5e38ec
commit 04d7466e0c
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
2 changed files with 64 additions and 69 deletions

View file

@ -1,27 +1,15 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": { "inputs": {
"lastModified": 1678901627, "systems": "systems"
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
}, },
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1689068808,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -32,32 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1680125544, "lastModified": 1688939073,
"narHash": "sha256-mlqo1r+TZUOuypWdrZHluxWL+E5WzXlUXNZ9Y0WLDFU=", "narHash": "sha256-jYhYjeK5s6k8QS3i+ovq9VZqBJaWbxm7awTKNhHL9d0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9a6aabc4740790ef3bbb246b86d029ccf6759658", "rev": "8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -65,26 +37,21 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "systems": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": { "locked": {
"lastModified": 1680229280, "lastModified": 1681028828,
"narHash": "sha256-9UoyQCeKUmHcsIdpsAgcz41LAIDkWhI2PhVDjckrpg0=", "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "oxalica", "owner": "nix-systems",
"repo": "rust-overlay", "repo": "default",
"rev": "aa480d799023141e1b9e5d6108700de63d9ad002", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "oxalica", "owner": "nix-systems",
"repo": "rust-overlay", "repo": "default",
"type": "github" "type": "github"
} }
} }

View file

@ -1,28 +1,56 @@
{ {
description = "Wiki Source"; description = "wiki.adtya.xyz";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
rust-overlay.url = "github:oxalica/rust-overlay"; flake-utils.url = "github:numtide/flake-utils";
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: outputs = {
flake-utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
overlays = [ (import rust-overlay) ]; flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system;
}; };
in in
with pkgs; { with pkgs; {
devShells.default = mkShell { formatter = pkgs.alejandra;
buildInputs = [ devShells.default = mkShell {
(rust-bin.stable.latest.default.override {extensions = [ "rust-src" "rust-analyzer" ];}) buildInputs = [
mdbook mdbook
]; ];
}; };
} packages.dockerImage = let
book = callPackage ./default.nix {};
in
dockerTools.buildImage {
name = "wiki.adtya.xyz";
tag = "latest";
fromImage = dockerTools.pullImage {
imageName = "nginx";
imageDigest =
if stdenv.isAarch64
then "sha256:9956d05e8f945ae928901c985936953e93eeb20f1b612b9851f8a5b02ba07b19"
else "sha256:da86ecb516d88a5b0579cec8687a75f974712cb5091560c06ef6c393ea4936ee";
sha256 =
if stdenv.isAarch64
then "1mpy68r0vqkyb8ls2p8msarhsljjkv3pwvl23wbhipygjv1gmqa4"
else "003cpzhjn5myy7myw79gzy9x1mzb2h9b4q1jwwzlhhjv08db9bal";
finalImageName = "nginx";
finalImageTag = "alpine-slim";
};
copyToRoot = book;
config = {
Cmd = ["nginx" "-g" "daemon off;"];
ExposedPort = {
"80/tcp" = {};
};
};
};
}
); );
} }