Skip to content

Commit

Permalink
fix(#112): ensure nix flake runs on Linux by using buildGoModule
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Sep 22, 2023
1 parent 712895e commit 0dbcfc3
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 546 deletions.
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
cmd/example/*.go
dist/
# Output.
cmd/templ/templ

# Logs.
cmd/templ/lspcmd/*log.txt
.DS_Store

# Go code coverage.
coverage.out
coverage

# Mac filesystem jank.
.DS_Store

# Docusaurus.
docs/build/
docs/resources/_gen/
node_modules/
dist/

# Nix artifacts.
result
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ See user documentation at https://templ.guide

## Tasks

### nix-develop

Run a Nix shell that contains everything required to build templ.

```sh
nix develop --impure
```

### build

Build a local version.
Expand Down
170 changes: 15 additions & 155 deletions flake.lock

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

84 changes: 28 additions & 56 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,65 +1,37 @@
{
description = "templ";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-22.11";
xc = {
url = "github:joerdav/xc";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
# Neovim 0.9.0
inputs.neovim-flake.url = "github:neovim/neovim?dir=contrib&rev=040f1459849ab05b04f6bb1e77b3def16b4c2f2b";
};
};

outputs = { self, flake-utils, nixpkgs, xc, neovim-nightly-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgsDefault = import nixpkgs { overlays = [ neovim-nightly-overlay.overlay ]; };
pkgs = import nixpkgs {
inherit system; overlays = [
(self: super: {
xc = xc.packages.${system}.xc;
neovim = import ./nix/nvim.nix { pkgs = pkgsDefault; };
gopls = pkgs.callPackage ./nix/gopls.nix { };
templ = pkgs.callPackage ./nix/templ.nix {
go = pkgs.go_1_20;
xc = self.xc;
};
nerdfonts = (pkgsDefault.nerdfonts.override { fonts = [ "IBMPlexMono" ]; });
})
];
};
shell = pkgs.mkShell {
packages = [
pkgs.asciinema
pkgs.git
pkgs.go
pkgs.gopls
pkgs.gotools
pkgs.ibm-plex
pkgs.neovim
pkgs.nerdfonts
pkgs.ripgrep
pkgs.silver-searcher
pkgs.templ
pkgs.tmux
pkgs.wget
pkgs.xc
pkgs.zip
];
};
outputs = { self, nixpkgs, gitignore }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];

# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
defaultPackage = pkgs.templ;
packages = {
templ = pkgs.templ;
};
devShells = {
default = shell;
{
packages = forAllSystems ({ pkgs }: {
default = pkgs.buildGoModule {
name = "templ";
src = gitignore.lib.gitignoreSource ./.;
subPackages = [ "./cmd/templ" ];
vendorSha256 = "sha256-7QYF8BvLpTcDstkLWxR0BgBP0NUlJ20IqW/nNqMSBn4=";
};
}
);
});
};
}
9 changes: 0 additions & 9 deletions nix/.config/nvim/lua/goimports.lua

This file was deleted.

5 changes: 0 additions & 5 deletions nix/.config/nvim/lua/init.lua

This file was deleted.

Loading

0 comments on commit 0dbcfc3

Please sign in to comment.