Compare commits

...

7 Commits

Author SHA1 Message Date
59f910fe3f
cura5: rework to include desktop item 2023-09-21 13:12:39 +10:00
93b6195542
all: refactor to follow RFC140 2023-09-21 12:28:32 +10:00
github-actions[bot]
029f6e7795
flake: update inputs (#63)
Flake lock file updates:

• Updated input 'flake-utils':
    'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/78058d810644f5ed276804ce7ea9e82d92bee293' (2023-09-10)
  → 'github:NixOS/nixpkgs/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db' (2023-09-17)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-18 10:05:15 +00:00
dependabot[bot]
19eb6aefbe
ci: bump cachix/install-nix-action from 22 to 23 (#61)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 23.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v22...v23)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-11 08:03:18 +00:00
dependabot[bot]
26b35fa847
ci: bump actions/checkout from 3 to 4 (#60)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-11 07:57:17 +00:00
github-actions[bot]
ec92a006c3
flake: update inputs (#62)
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/d816b5ab44187a2dd84806630ce77a733724f95f' (2023-09-03)
  → 'github:NixOS/nixpkgs/78058d810644f5ed276804ce7ea9e82d92bee293' (2023-09-10)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-11 07:57:09 +00:00
github-actions[bot]
622b3cbdfe
flake: update inputs (#59)
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/cddebdb60de376c1bdb7a4e6ee3d98355453fe56' (2023-08-27)
  → 'github:NixOS/nixpkgs/d816b5ab44187a2dd84806630ce77a733724f95f' (2023-09-03)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-06 01:21:01 +00:00
25 changed files with 209 additions and 79 deletions

View File

@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
- name: Check ${{ matrix.check }}
# Depends on nixos/nix#7759 to simply `nix flake check`
run: nix run .#checks.$(nix eval --raw --impure --expr "builtins.currentSystem").${{ matrix.check }}
@ -43,9 +43,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v22
uses: cachix/install-nix-action@v23
- name: Show nixpkgs version
run: nix eval --impure --expr '(import ./flake-compat.nix { src = ./.; }).lib.version'
- name: Setup cachix

View File

@ -11,8 +11,8 @@ jobs:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

View File

@ -1,15 +0,0 @@
{ pkgs
, lib ? pkgs.lib
, unitDir ? "unit"
, packageFun ? "package.nix"
, root ? "${./pkgs}/${unitDir}"
}:
let
shards = lib.attrNames (builtins.readDir root);
namesForShard = shard: lib.mapAttrs'
(name: _: { inherit name; value = root + "/${shard}/${name}"; })
(builtins.readDir (root + "/${shard}"));
namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards);
units = lib.mapAttrs (_: path: pkgs.callPackage (path + "/${packageFun}") { }) namesToPath;
in
units

View File

@ -8,10 +8,10 @@
{ pkgs ? import <nixpkgs> { } }:
let
legacy = import ./pkgs/top-level/all-packages.nix { inherit pkgs; };
units = import ./callUnitRoot.nix { inherit pkgs; root = ./pkgs/unit; };
system = pkgs.stdenv.hostPlatform.system;
packages = import ./pkgs/top-level { localSystem = system; inherit pkgs; };
in
legacy // units // {
packages // {
# The `lib`, `modules`, and `overlay` names are special
lib = import ./lib { inherit pkgs; }; # functions
modules = import ./modules; # NixOS modules

12
flake.lock generated
View File

@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1692799911,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1693145325,
"narHash": "sha256-Gat9xskErH1zOcLjYMhSDBo0JTBZKfGS0xJlIRnj6Rc=",
"lastModified": 1694948089,
"narHash": "sha256-d2B282GmQ9o8klc22/Rbbbj6r99EnELQpOQjWMyv0rU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cddebdb60de376c1bdb7a4e6ee3d98355453fe56",
"rev": "5148520bfab61f99fd25fb9ff7bfbb50dad3c9db",
"type": "github"
},
"original": {

View File

@ -15,16 +15,7 @@
pkgs = import nixpkgs { inherit system; };
in
{
# nixos/rfcs#140
# Only produces the package set of the proposed functionality.
# Unstable names are variables.
packages =
let
legacyPackages = import ./pkgs/top-level/all-packages.nix { inherit pkgs; };
unitPackages = import ./callUnitRoot.nix { inherit pkgs; };
onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ]));
in
onlyAvailable (legacyPackages // unitPackages);
packages = import ./pkgs/top-level { localSystem = system; inherit pkgs; };
checks = {
nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" ''

View File

@ -0,0 +1,94 @@
{ lib
, stdenv
, fetchurl
, writeScriptBin
, appimageTools
, copyDesktopItems
, makeDesktopItem
}:
let
pname = "cura5";
version = "5.4.0";
name = "${pname}-${version}";
cura5 = appimageTools.wrapType2 {
inherit pname version;
src = fetchurl {
url = "https://github.com/Ultimaker/Cura/releases/download/${version}/Ultimaker-Cura-${version}-linux-modern.AppImage";
hash = "sha256-QVv7Wkfo082PH6n6rpsB79st2xK2+Np9ivBg/PYZd74=";
};
extraPkgs = _: [ ];
};
script = writeScriptBin pname ''
#!${stdenv.shell}
# AppImage version of Cura loses current working directory and treats all paths relateive to $HOME.
# So we convert each of the files passed as argument to an absolute path.
# This fixes use cases like `cd /path/to/my/files; cura mymodel.stl anothermodel.stl`.
args=()
for a in "$@"; do
if [ -e "$a" ]; then
a="$(realpath "$a")"
fi
args+=("$a")
done
exec "${cura5}/bin/${name}" "''${args[@]}"
'';
in
stdenv.mkDerivation rec {
inherit pname version;
dontUnpack = true;
nativeBuildInputs = [ copyDesktopItems ];
desktopItems = [
# Based on upstream.
# https://github.com/Ultimaker/Cura/blob/main/packaging/AppImage/cura.desktop.jinja
(makeDesktopItem {
name = "cura";
desktopName = "UltiMaker Cura";
genericName = "3D Printing Software";
comment = meta.longDescription;
exec = "cura5";
icon = "cura-icon";
terminal = false;
type = "Application";
mimeTypes = [
"model/stl"
"application/vnd.ms-3mfdocument"
"application/prs.wavefront-obj"
"image/bmp"
"image/gif"
"image/jpeg"
"image/png"
"text/x-gcode"
"application/x-amf"
"application/x-ply"
"application/x-ctm"
"model/vnd.collada+xml"
"model/gltf-binary"
"model/gltf+json"
"model/vnd.collada+xml+zip"
];
categories = [ "Graphics" ];
keywords = [ "3D" "Printing" ];
})
];
# TODO: Extract cura-icon from AppImage source.
installPhase = ''
mkdir -p $out/bin
cp ${script}/bin/cura5 $out/bin/cura5
runHook postInstall
'';
meta = {
description = "3D printing software";
homepage = "https://github.com/ultimaker/cura";
longDescription = ''
Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.
'';
license = lib.licenses.lgpl3;
platforms = [ "x86_64-linux" ];
};
}

View File

@ -0,0 +1,56 @@
# This file turns the pkgs/by-name directory (see its README.md for more info)
# into an overlay that adds all the defined packages.
#
# No validity checks are done here, instead this file is optimised for
# performance, and validity checks are done by CI on PRs.
#
# This file is based on Nixpkgs' `pkgs/top-level/by-name-overlay.nix` in order
# to utilise the same infrastructure and layout, with some adjustments to fit
# our derivative project.
{ lib
, pkgs
}:
# Type: Path -> Overlay
baseDirectory:
let
inherit (builtins)
readDir
;
inherit (lib.attrsets)
mapAttrs
mapAttrsToList
mergeAttrsList
;
# Package files for a single shard
# Type: String -> String -> AttrsOf Path
namesForShard = shard: type:
if type != "directory" then
# Ignore all non-directories. Technically only README.md is allowed as a file in the base directory, so we could alternatively:
# - Assume that README.md is the only file and change the condition to `shard == "README.md"` for a minor performance improvement.
# This would however cause very poor error messages if there's other files.
# - Ensure that README.md is the only file, throwing a better error message if that's not the case.
# However this would make for a poor code architecture, because one type of error would have to be duplicated in the validity checks and here.
# Additionally in either of those alternatives, we would have to duplicate the hardcoding of "README.md"
{ }
else
mapAttrs
(name: _: baseDirectory + "/${shard}/${name}/package.nix")
(readDir (baseDirectory + "/${shard}"));
# The attribute set mapping names to the package files defining them
# This is defined up here in order to allow reuse of the value (it's kind of expensive to compute)
# if the overlay has to be applied multiple times
packageFiles = mergeAttrsList (mapAttrsToList namesForShard (readDir baseDirectory));
in
# TODO: Consider optimising this using `builtins.deepSeq packageFiles`,
# which could free up the above thunks and reduce GC times.
# Currently this would be hard to measure until we have more packages
# and ideally https://github.com/NixOS/nix/pull/8895
_self: _super:
mapAttrs
(_name: file: pkgs.callPackage file { })
packageFiles

View File

@ -0,0 +1,19 @@
# Composes the packages collection.
{
# The system packages will be build and used on.
localSystem
# Nixpkgs
, pkgs
# Nixpkgs lib
, lib ? pkgs.lib
}:
let
allPackages = import ./stage.nix {
inherit lib pkgs;
};
available = lib.filterAttrs
(_: drv: builtins.elem localSystem (drv.meta.platforms or [ ]));
in
available allPackages

24
pkgs/top-level/stage.nix Normal file
View File

@ -0,0 +1,24 @@
# Composes a single bootstrapping of the package collection. The result is a set
# of all the packages for some particular platform.
{ lib
, pkgs
}:
let
# An overlay to auto-call packages in .../by-name.
autoCalledPackages =
import ./by-name-overlay.nix { inherit pkgs lib; } ../by-name;
allPackages = _self: _super:
import ./all-packages.nix { inherit pkgs; };
toFix = (lib.flip lib.composeManyExtensions) (_self: { }) [
autoCalledPackages
allPackages
];
in
# Return the complete set of packages.
lib.fix toFix

View File

@ -1,39 +0,0 @@
{ stdenv
, fetchurl
, writeScriptBin
, appimageTools
}:
let
pname = "cura5";
version = "5.4.0";
name = "${pname}-${version}";
cura5 = appimageTools.wrapType2 {
inherit pname version;
src = fetchurl {
url = "https://github.com/Ultimaker/Cura/releases/download/${version}/Ultimaker-Cura-${version}-linux-modern.AppImage";
hash = "sha256-QVv7Wkfo082PH6n6rpsB79st2xK2+Np9ivBg/PYZd74=";
};
extraPkgs = _: [ ];
};
script = writeScriptBin pname ''
#!${stdenv.shell}
# AppImage version of Cura loses current working directory and treats all paths relateive to $HOME.
# So we convert each of the files passed as argument to an absolute path.
# This fixes use cases like `cd /path/to/my/files; cura mymodel.stl anothermodel.stl`.
args=()
for a in "$@"; do
if [ -e "$a" ]; then
a="$(realpath "$a")"
fi
args+=("$a")
done
exec "${cura5}/bin/${name}" "''${args[@]}"
'';
in
script // {
inherit name pname version;
meta.platforms = [ "x86_64-linux" ];
}