From a5df1afb0d2accc9d47bcbc4c1a4effe741940bd Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 27 Nov 2022 21:55:46 +0100 Subject: [PATCH] testing flake-based container --- .gitignore | 1 + .woodpecker-ci.yml | 10 ++++++++++ Dockerfile | 9 --------- flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 .woodpecker-ci.yml delete mode 100644 Dockerfile create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/.woodpecker-ci.yml b/.woodpecker-ci.yml new file mode 100644 index 0000000..8f003b0 --- /dev/null +++ b/.woodpecker-ci.yml @@ -0,0 +1,10 @@ +pipeline: + nix: + image: nixos/nix + commands: + - nix flake check + - nix build '.#mdbook-toc' + volumes: + - /nix/store:/nix/store + - /nix/var/nix/db:/nix/var/nix/db + - /nix/var/nix/daemon-socket:/nix/var/nix/daemon-socket diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 790c4e3..0000000 --- a/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine:3 as builder -RUN apk add --no-cache cargo -RUN cargo install mdbook -RUN cargo install mdbook-toc - -FROM alpine:3 -RUN apk add --no-cache libgcc -COPY --from=builder /root/.cargo/bin/mdbook /bin/mdbook -COPY --from=builder /root/.cargo/bin/mdbook-toc /bin/mdbook-toc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c2b8881 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1669411043, + "narHash": "sha256-LfPd3+EY+jaIHTRIEOUtHXuanxm59YKgUacmSzaqMLc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5dc7114b7b256d217fe7752f1614be2514e61bb8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2bd0e62 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "A very basic flake"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + packages = rec { + docker = pkgs.dockerTools.buildLayeredImage { + name = "mdbook-plus"; + contents = mdbook-toc; + config.Cmd = [ "${pkgs.mdbook}/bin/mdbook" ]; + }; + mdbook-toc = pkgs.rustPlatform.buildRustPackage rec { + pname = "mdbook-toc"; + version = "0.10.0"; + + src = pkgs.fetchFromGitHub { + owner = "badboy"; + repo = pname; + rev = version; + sha256 = "sha256-/MPxuzqgWKyLP1fn/WoA2cKlV0TiVidt+YpNqY96sxE="; + }; + + cargoSha256 = "sha256-JFqkeea6o5Wzpe+2Fp+UYjBOh/e3vX1pZzCfxxfAYmU="; + }; + }; + }); +}