Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit db45b90

Browse files
committed
refactor flakes
1 parent 5be6430 commit db45b90

File tree

5 files changed

+119
-127
lines changed

5 files changed

+119
-127
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
jobs:
2-
_1_update_flake_locks:
3-
name: Update flake locks
4-
runs-on: ubuntu-20.04
5-
steps:
6-
- name: Checkout this repo
7-
uses: actions/checkout@v3
8-
- name: Install Nix
9-
uses: cachix/install-nix-action@v18
10-
with:
11-
extra_nix_config: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}\nsubstituters = https://cache.nixos.org/ https://cache.iog.io https://nix-community.cachix.org https://deemp.cachix.org \ntrusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= haskell-language-server.cachix.org-1:juFfHrwkOxqIOZShtC4YC1uT1bBcq2RSvC7OMKx0Nz8= deemp.cachix.org-1:9shDxyR2ANqEPQEEYDL/xIOnoPwxHot21L5fiZnFL18=\n"
12-
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
13-
- name: Config git for github-actions
14-
run: |
15-
git config user.name github-actions
16-
git config user.email github-actions@github.com
17-
- name: Update flake locks
18-
run: |
19-
git pull --rebase --autostash
20-
nix run .#updateLocks
21-
git commit -a -m "action: Update flake locks" && git push || echo ""
222
_2_push_to_cachix:
233
name: Push to cachix
24-
needs: _1_update_flake_locks
254
runs-on: ${{ matrix.os }}
265
steps:
276
- name: Checkout this repo
@@ -49,7 +28,6 @@ jobs:
4928
- ubuntu-22.04
5029
_3_front:
5130
name: Publish front
52-
needs: _1_update_flake_locks
5331
runs-on: ubuntu-20.04
5432
steps:
5533
- name: Checkout this repo
@@ -70,8 +48,7 @@ jobs:
7048
github_token: ${{ secrets.GITHUB_TOKEN }}
7149
publish_dir: ./front/docs
7250
_4_back:
73-
name: Release to Heroku
74-
needs: _1_update_flake_locks
51+
name: Publish back
7552
runs-on: ubuntu-20.04
7653
steps:
7754
- name: Checkout this repo
@@ -82,7 +59,7 @@ jobs:
8259
extra_nix_config: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}\nsubstituters = https://cache.nixos.org/ https://cache.iog.io https://nix-community.cachix.org https://deemp.cachix.org \ntrusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= haskell-language-server.cachix.org-1:juFfHrwkOxqIOZShtC4YC1uT1bBcq2RSvC7OMKx0Nz8= deemp.cachix.org-1:9shDxyR2ANqEPQEEYDL/xIOnoPwxHot21L5fiZnFL18=\n"
8360
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
8461
- name: Log in to Heroku
85-
uses: deemp/heroku-deploy@master
62+
uses: AkhileshNS/heroku-deploy@master
8663
with:
8764
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
8865
heroku_app_name: try-phi-back

back/flake.nix

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
description = "Try-phi back end";
33
inputs = {
4-
nixpkgs_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/nixpkgs;
4+
nixpkgs_.url = github:deemp/flakes?dir=source-flake/nixpkgs;
55
nixpkgs.follows = "nixpkgs_/nixpkgs";
6-
flake-utils_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/flake-utils;
6+
flake-utils_.url = github:deemp/flakes?dir=source-flake/flake-utils;
77
flake-utils.follows = "flake-utils_/flake-utils";
8-
haskell-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=language-tools/haskell;
9-
devshell.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=devshell;
10-
drv-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=drv-tools;
11-
codium.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=codium;
8+
haskell-tools.url = github:deemp/flakes?dir=language-tools/haskell;
9+
devshell.url = github:deemp/flakes?dir=devshell;
10+
drv-tools.url = github:deemp/flakes?dir=drv-tools;
11+
codium.url = github:deemp/flakes?dir=codium;
1212
};
1313

1414
outputs =
@@ -17,7 +17,7 @@
1717
let
1818
pkgs = inputs.nixpkgs.legacyPackages.${system};
1919
inherit (inputs.codium.functions.${system}) writeSettingsJSON mkCodium;
20-
inherit (inputs.devshell.functions.${system}) mkShell mkCommands;
20+
inherit (inputs.devshell.functions.${system}) mkShell mkCommands mkRunCommands;
2121
inherit (inputs.drv-tools.functions.${system}) mkShellApps mkBin;
2222
inherit (inputs.haskell-tools.functions.${system}) toolsGHC;
2323
inherit (inputs.codium.configs.${system}) extensions settingsNix;
@@ -59,15 +59,19 @@
5959
cabal hpack callCabal justStaticExecutable
6060
callCabal2nix haskellPackages hls implicit-hie;
6161

62-
exeName = "back";
63-
back = justStaticExecutable exeName haskellPackages.${packageName};
62+
binaryName = "back";
63+
64+
back = justStaticExecutable {
65+
package = haskellPackages.${packageName};
66+
inherit binaryName;
67+
};
6468

6569
localImageName = "back";
6670
backImage = pkgs.dockerTools.buildLayeredImage {
6771
name = localImageName;
6872
tag = "latest";
6973
contents = [ back ];
70-
config.Entrypoint = [ exeName ];
74+
config.Entrypoint = [ binaryName ];
7175
};
7276

7377
scripts =
@@ -110,33 +114,38 @@
110114
description = "Release ${herokuAppName} on Heroku";
111115
};
112116
};
113-
scripts3 = {
114-
writeSettings = writeSettingsJSON {
115-
inherit (settingsNix) haskell todo-tree files editor gitlens
116-
git nix-ide workbench markdown-all-in-one markdown-language-features;
117-
};
118-
};
119117
in
120-
scripts1 // scripts2 // scripts3;
121-
codiumTools = [ hpack cabal pkgs.heroku implicit-hie ];
122-
codium = mkCodium {
123-
extensions = { inherit (extensions) nix haskell misc github markdown; };
124-
runtimeDependencies = codiumTools ++ [ hls ];
125-
};
126-
tools = codiumTools ++ [ codium ];
127-
in
128-
{
118+
scripts1 // scripts2;
119+
120+
tools = [ hpack cabal pkgs.heroku implicit-hie ];
121+
129122
packages = {
130123
default = back;
124+
125+
writeSettings = writeSettingsJSON {
126+
inherit (settingsNix) haskell todo-tree files editor gitlens
127+
git nix-ide workbench markdown-all-in-one markdown-language-features;
128+
};
129+
codium = mkCodium {
130+
extensions = { inherit (extensions) nix haskell misc github markdown; };
131+
runtimeDependencies = tools ++ [ hls ];
132+
};
131133
} // scripts;
132134

133135
devShells = {
134136
default = mkShell {
135137
packages = tools;
136138
bash.extra = ''export LANG="C.UTF-8";'';
137-
commands = mkCommands "tools" tools;
139+
commands =
140+
mkCommands "tools" tools ++
141+
mkRunCommands "ide" { "codium ." = packages.codium; inherit (packages) writeSettings; } ++
142+
mkRunCommands "image" { inherit (packages) dockerBuild dockerRun herokuRelease; }
143+
;
138144
};
139145
};
146+
in
147+
{
148+
inherit packages devShells;
140149

141150
image = backImage;
142151
});

flake.nix

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
inputs = {
3-
nixpkgs_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/nixpkgs;
3+
nixpkgs_.url = github:deemp/flakes?dir=source-flake/nixpkgs;
44
nixpkgs.follows = "nixpkgs_/nixpkgs";
5-
flake-utils_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/flake-utils;
5+
flake-utils_.url = github:deemp/flakes?dir=source-flake/flake-utils;
66
flake-utils.follows = "flake-utils_/flake-utils";
7-
flakes-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=flakes-tools;
8-
my-codium.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=codium;
9-
my-devshell.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=devshell;
10-
drv-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=drv-tools;
11-
purescript-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=language-tools/purescript;
12-
workflows.url = "github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=workflows";
7+
flakes-tools.url = github:deemp/flakes?dir=flakes-tools;
8+
my-codium.url = github:deemp/flakes?dir=codium;
9+
my-devshell.url = github:deemp/flakes?dir=devshell;
10+
drv-tools.url = github:deemp/flakes?dir=drv-tools;
11+
purescript-tools.url = github:deemp/flakes?dir=language-tools/purescript;
12+
workflows.url = "github:deemp/flakes?dir=workflows";
1313
};
1414
outputs =
1515
{ self
@@ -32,49 +32,46 @@
3232
inherit (flakes-tools.functions.${system}) mkFlakesTools;
3333
inherit (my-codium.configs.${system}) extensions settingsNix;
3434
pursTools = purescript-tools.toolSets.${system}.shellTools;
35-
inherit (my-devshell.functions.${system}) mkShell mkCommands;
35+
inherit (my-devshell.functions.${system}) mkShell mkRunCommands;
3636

3737
backDir = "back";
3838
frontDir = "front";
3939
scripts =
40-
(mkShellApps {
41-
back = {
42-
text = "cd ${backDir} && nix run";
43-
description = "Run backend";
40+
mkShellApps
41+
{
42+
back = {
43+
text = "cd ${backDir} && nix run";
44+
description = "Run backend";
45+
};
46+
front = {
47+
text = "cd ${frontDir} && nix run";
48+
description = "Run frontend";
49+
};
4450
};
45-
front = {
46-
text = "cd ${frontDir} && nix run";
47-
description = "Run frontend";
48-
};
49-
}) // {
50-
writeSettings = writeSettingsJSON settingsNix;
51-
writeWorkflows = import ./nix-files/workflow.nix {
52-
name = "ci";
53-
inherit workflows backDir frontDir system;
54-
};
55-
};
56-
57-
codiumTools = builtins.attrValues scripts;
5851

59-
codium = mkCodium {
60-
extensions = { inherit (extensions) nix misc github markdown; };
61-
runtimeDependencies = codiumTools;
62-
};
52+
packages = {
53+
inherit (mkFlakesTools [ "front" "back" "." ]) pushToCachix updateLocks;
6354

64-
tools = codiumTools ++ [ codium ];
55+
writeSettings = writeSettingsJSON settingsNix;
56+
codium = mkCodium {
57+
extensions = { inherit (extensions) nix misc github markdown; };
58+
};
6559

66-
flakesTools = mkFlakesTools [ "front" "back" "." ];
67-
in
68-
{
69-
packages = {
70-
pushToCachix = flakesTools.pushToCachix;
71-
updateLocks = flakesTools.updateLocks;
60+
writeWorkflows = import ./nix-files/workflow.nix {
61+
name = "ci";
62+
inherit workflows backDir frontDir system;
63+
};
7264
} // scripts;
7365

7466
devShells.default = mkShell {
75-
packages = tools;
76-
commands = mkCommands "tools" tools;
67+
commands =
68+
mkRunCommands "ide" { "codium ." = packages.codium; inherit (packages) writeSettings; } ++
69+
mkRunCommands "infra" { inherit (packages) writeWorkflows pushToCachix updateLocks; }
70+
;
7771
};
72+
in
73+
{
74+
inherit packages devShells;
7875
});
7976

8077
nixConfig = {

front/flake.nix

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,63 @@
22
description = "Try-phi front end";
33

44
inputs = {
5-
nixpkgs_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/nixpkgs;
5+
nixpkgs_.url = github:deemp/flakes?dir=source-flake/nixpkgs;
66
nixpkgs.follows = "nixpkgs_/nixpkgs";
7-
flake-utils_.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=source-flake/flake-utils;
7+
flake-utils_.url = github:deemp/flakes?dir=source-flake/flake-utils;
88
flake-utils.follows = "flake-utils_/flake-utils";
9-
drv-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=drv-tools;
10-
purescript-tools.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=language-tools/purescript;
11-
devshell.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=devshell;
12-
codium.url = github:deemp/flakes/e306bf22309d95557ab569a2672184a64fb3f7d2?dir=codium;
9+
drv-tools.url = github:deemp/flakes?dir=drv-tools;
10+
purescript-tools.url = github:deemp/flakes?dir=language-tools/purescript;
11+
devshell.url = github:deemp/flakes?dir=devshell;
12+
codium.url = github:deemp/flakes?dir=codium;
1313
};
1414

1515
outputs = inputs:
1616
inputs.flake-utils.lib.eachDefaultSystem (system:
1717
let
1818
pkgs = inputs.nixpkgs.legacyPackages.${system};
1919
shellTools = inputs.purescript-tools.shellTools.${system};
20-
inherit (inputs.devshell.functions.${system}) mkShell mkCommands;
20+
inherit (inputs.devshell.functions.${system}) mkShell mkCommands mkRunCommands;
2121
inherit (inputs.drv-tools.functions.${system}) mkShellApps;
2222
inherit (inputs.codium.configs.${system}) extensions settingsNix;
2323
inherit (inputs.codium.functions.${system}) writeSettingsJSON mkCodium;
2424
inherit (builtins) attrValues;
25-
25+
2626
scripts = mkShellApps {
2727
default = {
2828
text = "npm run quick-start";
2929
runtimeInputs = [ shellTools.nodejs-16_x ];
30+
description = "Run front";
3031
};
3132
buildGHPages = {
3233
text = ''npm run build:gh-pages'';
3334
runtimeInputs = [ shellTools.nodejs-16_x ];
35+
description = "Build GitHub Pages";
3436
};
3537
};
3638

37-
codiumTools = attrValues { inherit (shellTools) purescript nodejs-16_x spago; };
38-
codium = mkCodium {
39-
extensions = { inherit (extensions) nix misc github markdown purescript; };
40-
runtimeDependencies = codiumTools ++ (attrValues {
41-
inherit (shellTools) dhall-lsp-server purescript-language-server purs-tidy;
42-
});
43-
};
39+
tools = with shellTools; [ purescript nodejs-16_x spago ];
40+
41+
packages = {
42+
codium = mkCodium {
43+
extensions = { inherit (extensions) nix misc github markdown purescript; };
44+
runtimeDependencies = tools ++ (attrValues {
45+
inherit (shellTools) dhall-lsp-server purescript-language-server purs-tidy;
46+
});
47+
};
48+
writeSettings = writeSettingsJSON settingsNix;
49+
} // scripts;
4450

45-
tools = codiumTools ++ [ codium ];
46-
in
47-
{
48-
packages = scripts;
4951
devShells.default = mkShell {
5052
packages = tools;
51-
commands = mkCommands "tools" tools;
53+
commands =
54+
mkCommands "tools" tools ++
55+
mkRunCommands "ide" { "codium ." = packages.codium; inherit (packages) writeSettings; } ++
56+
mkRunCommands "scripts" { inherit (packages) default buildGHPages; }
57+
;
5258
};
59+
in
60+
{
61+
inherit packages devShells;
5362
});
5463

5564
nixConfig = {

0 commit comments

Comments
 (0)