-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create Nix flake to use in Dockerfile
- Loading branch information
Showing
4 changed files
with
65 additions
and
51 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,28 @@ | ||
# syntax=docker/dockerfile:1.7 | ||
|
||
# Nix builder | ||
FROM nixos/nix:latest AS builder | ||
|
||
# Copy our source and setup our working dir | ||
COPY . /tmp/build | ||
WORKDIR /tmp/build | ||
|
||
# Build our Nix environment | ||
RUN nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
build | ||
|
||
# Copy the Nix store closure into a directory | ||
RUN mkdir /tmp/nix-store-closure | ||
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure | ||
|
||
# Final image | ||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
# Copy /nix/store | ||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/build/result /app | ||
CMD ["/app/bin/app"] |
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,37 @@ | ||
{ | ||
description = "simde"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
pnpm2nix = { | ||
url = "github:nzbr/pnpm2nix-nzbr"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, pnpm2nix, ... } @ inputs: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let pkgs = import nixpkgs { inherit system; }; | ||
in with pkgs; rec { | ||
# Development environment | ||
devShell = mkShell { | ||
name = "simde"; | ||
nativeBuildInputs = [ nodejs nodePackages.pnpm ]; | ||
}; | ||
|
||
# Build package into dist/ dir with pnpm | ||
dist = pnpm2nix.packages.${system}.mkPnpmPackage { | ||
src = ./.; | ||
}; | ||
|
||
# Create SIMDE dist/ + SWS bundle | ||
packages.app = pkgs.writeShellScriptBin "app" '' | ||
${pkgs.static-web-server}/bin/static-web-server --root ${dist}.distDir | ||
''; | ||
|
||
# The default package when a specific package name isn't specified | ||
defaultPackage = packages.app; | ||
} | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.