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 = ./.; |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 26 | } [ |
TheCodedProf | 7a182d8 | 2023-06-07 17:23:55 -0400 | [diff] [blame] | 27 | (pnpm2nix.mkPnpmPackage.${system}) |
| 28 | (pnpm2nix.mkPnpmEnv.${system}) |
TheCodedProf | 4a7c25d | 2023-06-07 17:09:45 -0400 | [diff] [blame] | 29 | ]; |
| 30 | |
| 31 | packages.default = let |
| 32 | packageJSON = (builtins.fromJSON (builtins.readFile ./package.json)); |
| 33 | in pkgs.stdenv.mkDerivation { |
| 34 | pname = "nucleus"; |
| 35 | version = packageJSON.version; |
| 36 | |
| 37 | src = ./.; |
| 38 | |
| 39 | buildInputs = [ packages.env nodejs nodePackages.pnpm ]; |
| 40 | nativeBuildInputs = [ packages.env nodePackages.pnpm ]; |
| 41 | |
| 42 | buildPhase = '' |
| 43 | pnpm run build |
| 44 | ''; |
| 45 | |
| 46 | installPhase = '' |
| 47 | cp dist $out |
| 48 | mkdir -p $out/bin |
| 49 | echo "#!/usr/bin/env bash\ncd $out\n${packageJSON.scripts.start}" > $out/bin/nucleus |
| 50 | ''; |
| 51 | }; |
| 52 | |
| 53 | dockerImage = let |
| 54 | nucleus = packages.default; |
| 55 | in pkgs.dockerTools.streamLayeredImage { |
| 56 | name = "nucleus"; |
| 57 | tag = "latest"; |
| 58 | contents = [ nucleus ]; |
| 59 | config.Cmd = [ "${nucleus}/bin/nucleus" ]; |
| 60 | }; |
Skyler Grey | 453b999 | 2023-03-05 05:48:42 +0000 | [diff] [blame] | 61 | }); |
TheCodedProf | a0e072a | 2023-04-22 19:57:56 -0400 | [diff] [blame] | 62 | } |