Skip to content

Commit

Permalink
Merge pull request #301 from Defelo/update_flake_lock_action
Browse files Browse the repository at this point in the history
Update flake.lock
  • Loading branch information
Defelo committed Apr 18, 2024
2 parents 2a229ce + 0489868 commit 6cba1be
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
30 changes: 15 additions & 15 deletions flake.lock

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

2 changes: 1 addition & 1 deletion nix/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pkgs-master = import inputs.nixpkgs-master {inherit system;};

removeSuffix = pkgs.lib.removeSuffix ".nix";
isPackage = name: name != "default.nix" && pkgs.lib.hasSuffix ".nix" name;
isPackage = name: name != "default.nix";
packageNames = builtins.filter isPackage (builtins.attrNames (builtins.readDir ./.));
packages = builtins.listToAttrs (map (name: {
name = removeSuffix name;
Expand Down
4 changes: 3 additions & 1 deletion nix/packages/uiua.nix → nix/packages/uiua/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{pkgs-master, ...}: let
uiua = pkgs-master.uiua;
uiua = pkgs-master.uiua.overrideAttrs ({patches ? [], ...}: {
patches = patches ++ [./fix-reading-readonly-files.patch];
});
in {
name = "Uiua";
version = uiua.version;
Expand Down
54 changes: 54 additions & 0 deletions nix/packages/uiua/fix-reading-readonly-files.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/src/sys.rs b/src/sys.rs
index a5388a57..034198e2 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -743,12 +743,12 @@ pub trait SysBackend: Any + Send + Sync + 'static {
Err("Creating files is not supported in this environment".into())
}
/// Open a file
- fn open_file(&self, path: &Path) -> Result<Handle, String> {
+ fn open_file(&self, path: &Path, write: bool) -> Result<Handle, String> {
Err("Opening files is not supported in this environment".into())
}
/// Read all bytes from a file
fn file_read_all(&self, path: &Path) -> Result<Vec<u8>, String> {
- let handle = self.open_file(path)?;
+ let handle = self.open_file(path, false)?;
let bytes = self.read(handle, usize::MAX)?;
self.close(handle)?;
Ok(bytes)
@@ -1020,7 +1020,7 @@ impl SysOp {
SysOp::FOpen => {
let path = env.pop(1)?.as_string(env, "Path must be a string")?;
let handle = (env.rt.backend)
- .open_file(path.as_ref())
+ .open_file(path.as_ref(), true)
.map_err(|e| env.error(e))?
.value(HandleKind::File(path.into()));
env.push(handle);
diff --git a/src/sys_native.rs b/src/sys_native.rs
index bf598ec6..d192f286 100644
--- a/src/sys_native.rs
+++ b/src/sys_native.rs
@@ -206,18 +206,18 @@ impl SysBackend for NativeSys {
}
Ok(paths)
}
- fn open_file(&self, path: &Path) -> Result<Handle, String> {
+ fn open_file(&self, path: &Path, write: bool) -> Result<Handle, String> {
let handle = NATIVE_SYS.new_handle();
let file = OpenOptions::new()
.read(true)
- .write(true)
+ .write(write)
.open(path)
.map_err(|e| format!("{e} {}", path.display()))?;
NATIVE_SYS.files.insert(handle, Buffered::new_reader(file));
Ok(handle)
}
fn file_read_all(&self, path: &Path) -> Result<Vec<u8>, String> {
- let handle = self.open_file(path)?;
+ let handle = self.open_file(path, false)?;
let bytes = self.read_all(handle)?;
self.close(handle)?;
Ok(bytes)

0 comments on commit 6cba1be

Please sign in to comment.