Compare commits

..

No commits in common. "59f910fe3f92420e5f68f0090cddb29f59a5d97b" and "6be9b3fd57fdca708c237cd0a52dfdbc56cb9483" have entirely different histories.

25 changed files with 79 additions and 209 deletions

View File

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

View File

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

15
callUnitRoot.nix Normal file
View File

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

12
flake.lock generated
View File

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

View File

@ -15,7 +15,16 @@
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
in in
{ {
packages = import ./pkgs/top-level { localSystem = system; inherit pkgs; }; # 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);
checks = { checks = {
nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" '' nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" ''

View File

@ -1,94 +0,0 @@
{ 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

@ -1,56 +0,0 @@
# 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

@ -1,19 +0,0 @@
# 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

View File

@ -1,24 +0,0 @@
# 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

@ -0,0 +1,39 @@
{ 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" ];
}