-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add flake.nix and other files #1231
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b503bb
feat(tooling): Enable use as a Nix flake
doronbehar fe7637a
docs(readme): Add note about using via Nix flake
doronbehar dd1e149
docs(manual): Add note about using via Nix flake
alerque 4dfa5e7
chore(build): Inform Nix flake about current libtexpdf version
alerque cb6df6c
chore(build): Include Nix tooling in source distribution
alerque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,6 @@ sile.1 | |
/.version-prev | ||
/.tarball-version | ||
/.built-subdirs | ||
|
||
# Nix symlink to builds | ||
/result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix | ||
(import ( | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
in fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; } | ||
) { | ||
src = ./.; | ||
}).defaultNix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
description = "Simon’s Improved Layout Engine"; | ||
|
||
# To make user overrides of the nixpkgs flake not take effect | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix | ||
inputs.flake-compat = { | ||
url = "github:edolstra/flake-compat"; | ||
flake = false; | ||
}; | ||
|
||
outputs = { self | ||
, nixpkgs | ||
, flake-utils | ||
, flake-compat | ||
}: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
# TODO: Should this be replaced with libtexpdf package from nixpkgs? or | ||
# should we keep it that way, so that it'd be easy to test new versions | ||
# of libtexpdf when developing? | ||
libtexpdf-src = builtins.fetchGit { | ||
url = "https://github.com/sile-typesetter/libtexpdf"; | ||
rev = "${(pkgs.lib.fileContents "${self}/libtexpdf.git-rev")}"; | ||
}; | ||
# https://discourse.nixos.org/t/passing-git-commit-hash-and-tag-to-build-with-flakes/11355/2 | ||
version_rev = if (self ? rev) then (builtins.substring 0 8 self.rev) else "dirty"; | ||
# Use the expression from Nixpkgs instead of rewriting it here. | ||
sile = pkgs.sile.overrideAttrs(oldAttr: rec { | ||
version = "${(pkgs.lib.importJSON ./package.json).version}-${version_rev}-flake"; | ||
src = builtins.filterSource | ||
(path: type: type != "directory" || baseNameOf path != ".git") | ||
./.; | ||
# Add the libtexpdf src instead of the git submodule. | ||
preAutoreconf = '' | ||
rm -rf ./libtexpdf | ||
# From some reason without this flag, libtexpdf/ is unwriteable | ||
cp --no-preserve=mode -r ${libtexpdf-src} ./libtexpdf/ | ||
''; | ||
# Pretend to be a tarball release so sile --version will not say `vUNKNOWN`. | ||
postAutoreconf = '' | ||
echo ${version} > .tarball-version | ||
''; | ||
# Don't build the manual as it's time consuming, and it requires fonts | ||
# that are not available in the sandbox due to internet connection | ||
# missing. | ||
configureFlags = pkgs.lib.lists.remove "--with-manual" oldAttr.configureFlags; | ||
nativeBuildInputs = oldAttr.nativeBuildInputs ++ [ | ||
pkgs.autoreconfHook | ||
]; | ||
# TODO: This switch between the hooks can be moved to Nixpkgs' | ||
postPatch = oldAttr.preConfigure; | ||
doronbehar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
preConfigure = ""; | ||
meta = oldAttr.meta // { | ||
changelog = "https://github.com/sile-typesetter/sile/raw/master/CHANGELOG.md"; | ||
}; | ||
}); | ||
in rec { | ||
devShell = pkgs.mkShell { | ||
inherit (sile) checkInputs nativeBuildInputs buildInputs; | ||
}; | ||
packages.sile = sile; | ||
defaultPackage = sile; | ||
apps.sile = { | ||
type = "app"; | ||
program = "${sile}/bin/sile"; | ||
}; | ||
defaultApp = apps.sile; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c4ff429664607e1f055d29aeb5dc5d4b6ddb2499 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix | ||
(import ( | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
in fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; } | ||
) { | ||
src = ./.; | ||
}).shellNix |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should filter these files as well right here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that will help, if
$CWD
is still set to the project directory when it is actually run it won't matter what was or wasn't copied into the Nix build, SILE will still prefer local resources to it's distribution ones. This is intentional so that users can override virtually anything in the system, but it does make the assumption that any resources in$CWD
should be usable.In any case this is a developer only problem and I'm not too worried about it. I've scheduled this for merge so I can test it out on the SILE website before tagging a release. We can issue any adjustments for more developer convenience in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @ctrlcctrlv noted, this is really the same as #1212. I'm not sure what the solution should even be (maybe nothing), but lets move discussion there.