Skip to content

Commit

Permalink
chore: refactor nix
Browse files Browse the repository at this point in the history
- fix roc path
- replace flake-utils with genAttrs
- use node v20?
- corepack enable for future pnpm?
  • Loading branch information
ricardo-valero authored and ivan-demchenko committed Feb 26, 2024
1 parent 9cbcd46 commit d53277f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 81 deletions.
72 changes: 12 additions & 60 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 36 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
roc = {
url = "github:roc-lang/roc";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
node = pkgs.nodejs_18;
# NOTE: this includes the cli as well as the lang server
# we could switch to .lang-server if we wanted to be slightly smaller on the dep
roc-full = inputs.roc.packages.${system}.full;
in {
formatter = pkgs.nixpkgs-fmt;
devShells = {
default = pkgs.mkShell {
buildInputs = [ node roc-full ];
shellHook = ''
export ROC_LSP_PATH=${roc-full}/bin/roc_ls
'';
};
};
});
outputs = {
nixpkgs,
roc,
...
}: let
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
in {
formatter = nixpkgs.lib.genAttrs systems (
system: let
pkgs = import nixpkgs {inherit system;};
in
pkgs.nixpkgs-fmt
);
devShells = nixpkgs.lib.genAttrs systems (system: let
pkgs = import nixpkgs {inherit system;};
rocPkgs = roc.packages.${system};
node = pkgs.nodejs_20;
corepackEnable = pkgs.runCommand "corepack-enable" {} ''
mkdir -p $out/bin
${node}/bin/corepack enable --install-directory $out/bin
'';
in {
default = pkgs.mkShell {
buildInputs = [
corepackEnable
node
# NOTE: this includes the cli as well as the language server
# we could switch it if we wanted to be slightly smaller on the dep
(with rocPkgs; [full])
];
shellHook = ''
export ROC_LSP_PATH=${rocPkgs.full}/bin/roc_language_server
'';
};
});
};
}

0 comments on commit d53277f

Please sign in to comment.