From e959f54b07aa3a2675a942bd5d9e621c2c15cd88 Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 12 Nov 2022 03:58:54 +0100 Subject: flake: add devshell and VM sandbox --- flake.lock | 16 ++++++++++++++++ flake.nix | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 45b4c6d..48222a4 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,21 @@ "type": "github" } }, + "flaky-utils": { + "locked": { + "lastModified": 1668221526, + "narHash": "sha256-cUtnjzEIgnfohdb0UhPU0ZVYyJ9USQhUwnEXexLlMNc=", + "ref": "master", + "rev": "bfa3be010c8c90f1bd0326747b9b424535381bb2", + "revCount": 11, + "type": "git", + "url": "https://cgit.pacien.net/libs/flaky-utils" + }, + "original": { + "type": "git", + "url": "https://cgit.pacien.net/libs/flaky-utils" + } + }, "nixpkgs": { "locked": { "lastModified": 1662019588, @@ -34,6 +49,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "flaky-utils": "flaky-utils", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 93d4f2e..d9dbbd9 100644 --- a/flake.nix +++ b/flake.nix @@ -22,14 +22,27 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; + flaky-utils.url = "git+https://cgit.pacien.net/libs/flaky-utils"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, flaky-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; ldgalleryVersion = "2.1"; + devTools = with pkgs; [ + # generic + tmux - in rec { + # viewer + nodejs-16_x + yarn + + # compiler + stack + ]; + + in pkgs.lib.fold pkgs.lib.recursiveUpdate { } [ + (rec { packages = rec { compiler = pkgs.haskell.lib.compose.overrideCabal (super: { pname = "ldgallery-compiler"; @@ -138,5 +151,25 @@ default = ldgallery; }; - }); + + devShell = flaky-utils.lib.mkDevShell { + inherit pkgs; + tools = devTools; + shell = null; + }; + }) + + (flaky-utils.lib.mkSandboxSystem { + inherit nixpkgs system; + restrictNetwork = false; + patchQemu9p = true; + config = { + environment.systemPackages = devTools; + virtualisation.forwardPorts = [ + { from = "host"; host.port = 8085; guest.port = 8085; } # vue-cli + ]; + }; + }) + + ]); } -- cgit v1.2.3