Jump to content

OpenSCAD: Difference between revisions

From Official NixOS Wiki
Created page with "OpenSCAD is a software for creating solid 3D CAD objects."
 
Add examples
Line 1: Line 1:
OpenSCAD is a software for creating solid 3D CAD objects.
OpenSCAD is a software for creating solid 3D CAD objects.
== OpenSCAD development environments with Nix ==
It is possible to create development envrionemtns with pinned version of OpenSCAD and the libraries you may want to use in your models. There are a number of different ways to do it.
=== Via <code>flake.nix</code> (recommended) ===
<syntaxhighlight lang="nix">
{
  description = "A very basic OpenSCAD devshell";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };
  outputs =
    { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = [
          (pkgs.openscad.withPackages (ps: [
            ps.bosl2
          ]))
        ];
      };
    };
}
</syntaxhighlight>
=== Via <code>shell.nix</code> ===
<syntaxhighlight lang="nix">let
  # We pin to a specific nixpkgs commit for reproducibility.
  # Last updated: 2026-09-06. Check for new commits at https://status.nixos.org.
  pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/17de0b976395537756f30a3e78f2f06e5cec89ed.tar.gz") {};
in
pkgs.mkShell {
  buildInputs = [
    (pkgs.openscadPackages.openscad.withPackages (ps: [ ps.bosl2 ]))
  ];
}</syntaxhighlight>

Revision as of 15:54, 6 September 2026

OpenSCAD is a software for creating solid 3D CAD objects.

OpenSCAD development environments with Nix

It is possible to create development envrionemtns with pinned version of OpenSCAD and the libraries you may want to use in your models. There are a number of different ways to do it.

Via flake.nix (recommended)

{
  description = "A very basic OpenSCAD devshell";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs =
    { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = [
          (pkgs.openscad.withPackages (ps: [
            ps.bosl2
          ]))
        ];
      };
    };
}

Via shell.nix

let
  # We pin to a specific nixpkgs commit for reproducibility.
  # Last updated: 2026-09-06. Check for new commits at https://status.nixos.org.
  pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/17de0b976395537756f30a3e78f2f06e5cec89ed.tar.gz") {};
in
pkgs.mkShell {
  buildInputs = [
    (pkgs.openscadPackages.openscad.withPackages (ps: [ ps.bosl2 ]))
  ];
}