Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 1 | { |
| 2 | description = "A basic flake with a shell"; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 3 | inputs.nixpkgs.follows = "clicks-server/nixpkgs"; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 4 | inputs.flake-utils.url = "github:numtide/flake-utils"; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 5 | inputs.clicks-server.url = "github:clicksminuteper/nixfiles"; |
| 6 | inputs.pnpm2nix.url = "github:clicksminuteper/pnpm2nix"; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 7 | |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 8 | inputs.pnpm2nix.inputs.nixpkgs.follows = "nixpkgs"; |
| 9 | |
| 10 | outputs = { self, nixpkgs, flake-utils, clicks-server, pnpm2nix }: |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 11 | flake-utils.lib.eachDefaultSystem (system: let |
| 12 | pkgs = nixpkgs.legacyPackages.${system}; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 13 | nodejs = pkgs.nodejs-19_x; |
| 14 | nodePackages = pkgs.nodePackages_latest; |
| 15 | lib = pkgs.lib; |
| 16 | in rec { |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 17 | devShells.default = pkgs.mkShell { |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 18 | packages = [ nodejs nodePackages.pnpm ]; |
TheCodedProf | a0e072a | 2023-04-22 19:57:56 -0400 | [diff] [blame] | 19 | shellHook = '' |
| 20 | unset name |
| 21 | ''; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 22 | }; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame^] | 23 | |
| 24 | packages.env = lib.pipe { |
| 25 | src = ./.; |
| 26 | packageJSON = ./package.json; |
| 27 | } [ |
| 28 | pnpm2nix.mkPnpmPackage |
| 29 | pnpm2nix.mkPnpmEnv |
| 30 | ]; |
| 31 | |
| 32 | packages.default = let |
| 33 | packageJSON = (builtins.fromJSON (builtins.readFile ./package.json)); |
| 34 | in pkgs.stdenv.mkDerivation { |
| 35 | pname = "nucleus"; |
| 36 | version = packageJSON.version; |
| 37 | |
| 38 | src = ./.; |
| 39 | |
| 40 | buildInputs = [ packages.env nodejs nodePackages.pnpm ]; |
| 41 | nativeBuildInputs = [ packages.env nodePackages.pnpm ]; |
| 42 | |
| 43 | buildPhase = '' |
| 44 | pnpm run build |
| 45 | ''; |
| 46 | |
| 47 | installPhase = '' |
| 48 | cp dist $out |
| 49 | mkdir -p $out/bin |
| 50 | echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus |
| 51 | ''; |
| 52 | }; |
| 53 | |
| 54 | dockerImage = let |
| 55 | nucleus = packages.default; |
| 56 | in pkgs.dockerTools.streamLayeredImage { |
| 57 | name = "nucleus"; |
| 58 | tag = "latest"; |
| 59 | contents = [ nucleus ]; |
| 60 | config.Cmd = [ "${nucleus}/bin/nucleus" ]; |
| 61 | }; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 62 | }); |
TheCodedProf | a0e072a | 2023-04-22 19:57:56 -0400 | [diff] [blame] | 63 | } |