Skip to content

Commit

Permalink
✨ Add nix flake infrastructure
Browse files Browse the repository at this point in the history
I've added a flake.nix and default.nix to handle
the package, a shell.nix to handle the development
environment and gomod2nix deals with go modules.
  • Loading branch information
arthsmn authored and gwennlbh committed Jul 18, 2024
1 parent 64da633 commit 024df2a
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ logs
*.vsix
hyprls
hyprls
result/
3 changes: 2 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ latestTag := `git describe --tags --abbrev=0 || echo commit:$(git rev-parse --sh

release tag:
jq '.version = "{{ tag }}"' < vscode/package.json | sponge vscode/package.json
git add vscode/package.json
sed -i "s/$(grep 'version' default.nix)/ version = \"{{ tag }}\";/" default.nix
git add vscode/package.json default.nix
git commit -m "🏷️ Release {{ tag }}"
git tag -- v{{ tag }}
cd vscode; bun vsce package; bun vsce publish
Expand Down
22 changes: 22 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:

buildGoApplication {
pname = "hyprls";
version = "0.2.0";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
checkFlags = ["-skip=TestHighLevelParse"]; # not yet implemented
}
85 changes: 85 additions & 0 deletions flake.lock

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

31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
description = "A LSP server for Hyprland config files";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gomod2nix.url = "github:nix-community/gomod2nix";
gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
gomod2nix.inputs.flake-utils.follows = "flake-utils";
};

outputs = { self, nixpkgs, flake-utils, gomod2nix }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};

# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
in
{
packages.default = callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};
})
);
}
63 changes: 63 additions & 0 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
schema = 3

[mod]
[mod."github.com/MakeNowJust/heredoc"]
version = "v1.0.0"
hash = "sha256-8hKERAVV1Pew84kc9GkW23dcO8uIUx/+tJQLi+oPwqE="
[mod."github.com/PuerkitoBio/goquery"]
version = "v1.5.1"
hash = "sha256-GqxIdhuN1L3enT8pNlWm+rmkdN5uMfF8TfpxhAHhEDQ="
[mod."github.com/anaskhan96/soup"]
version = "v1.2.5"
hash = "sha256-t8yCyK2y7x2qaI/3Yw16q3zVFqu+3acLcPgTr1MIKWg="
[mod."github.com/andybalholm/cascadia"]
version = "v1.1.0"
hash = "sha256-mL40/Q9iXBzzMHwMomqTOpp9rnI/MRsufb5cIU1MMPg="
[mod."github.com/davecgh/go-spew"]
version = "v1.1.1"
hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI="
[mod."github.com/evorts/html-to-markdown"]
version = "v0.0.10"
hash = "sha256-JV/v/rbKakJuSUTcOtRabeB0EzZRL+Nw5fYW5DRMxPg="
[mod."github.com/mazznoer/csscolorparser"]
version = "v0.1.3"
hash = "sha256-v8WyeQKL+SkOar4nftTFrvyitVjFPZRoVeuksp8OnMk="
[mod."github.com/metal3d/go-slugify"]
version = "v0.0.0-20160607203414-7ac2014b2f23"
hash = "sha256-vAfoTRKnDwLi7xLmFXP88auA8ZLJ8W6sLIj569hlkTk="
[mod."github.com/segmentio/asm"]
version = "v1.2.0"
hash = "sha256-zbNuKxNrUDUc6IlmRQNuJQzVe5Ol/mqp7srDg9IMMqs="
[mod."github.com/segmentio/encoding"]
version = "v0.4.0"
hash = "sha256-4pWI9eTZRRDP9kO8rG6vbLCtBVVRLtbCJKd0Z2+8JoU="
[mod."github.com/yuin/goldmark"]
version = "v1.7.1"
hash = "sha256-3EUgwoZRRs2jNBWSbB0DGNmfBvx7CeAgEwyUdaRaeR4="
[mod."go.lsp.dev/jsonrpc2"]
version = "v0.10.0"
hash = "sha256-RbRsMYVBLR7ZDHHGMooycrkdbIauMXkQjVOGP7ggSgM="
[mod."go.lsp.dev/pkg"]
version = "v0.0.0-20210717090340-384b27a52fb2"
hash = "sha256-TxS0Iqe1wbIaFe7MWZJRQdgqhKE8i8CggaGSV9zU1Vg="
[mod."go.lsp.dev/protocol"]
version = "v0.12.0"
hash = "sha256-rZgWIQpHHeYpJL8kiHJ21m1BHXAcr+4Xv2Yh9RNw3s4="
[mod."go.lsp.dev/uri"]
version = "v0.3.0"
hash = "sha256-jGP0N7Gf+bql5oJraUo33sXqWg7AKOTj0D8b4paV4dc="
[mod."go.uber.org/multierr"]
version = "v1.11.0"
hash = "sha256-Lb6rHHfR62Ozg2j2JZy3MKOMKdsfzd1IYTR57r3Mhp0="
[mod."go.uber.org/zap"]
version = "v1.27.0"
hash = "sha256-8655KDrulc4Das3VRduO9MjCn8ZYD5WkULjCvruaYsU="
[mod."golang.org/x/net"]
version = "v0.0.0-20200320220750-118fecf932d8"
hash = "sha256-YdLYymyqwWmiBR6QJdgvOq+QbQvmAh2VAk4KnB+GZAQ="
[mod."golang.org/x/sys"]
version = "v0.19.0"
hash = "sha256-cmuL31TYLJmDm/fDnI2Sn0wB88cpdOHV1+urorsJWx4="
[mod."golang.org/x/text"]
version = "v0.3.0"
hash = "sha256-0FFbaxF1ZuAQF3sCcA85e8MO6prFeHint36inija4NY="
29 changes: 29 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, mkGoEnv ? pkgs.mkGoEnv
, gomod2nix ? pkgs.gomod2nix
}:

let
goEnv = mkGoEnv { pwd = ./.; };
in
pkgs.mkShell {
packages = [
goEnv
gomod2nix
] ++ (with pkgs; [
just
jq
moreutils # sponge
bun
]);
}

0 comments on commit 024df2a

Please sign in to comment.